Skip to content

Commit b777503

Browse files
committed
source-mysql: Ignore ROLLBACK query events
Generally speaking we shouldn't see BEGIN/COMMIT/ROLLBACK events in the binlog, and we can't actually support a rollback on a table that we're actively processing since we've already emitted the changes. But since we do see them in certain edge cases we ought to ignore them properly.
1 parent 85638f0 commit b777503

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source-mysql/replication.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ func mergePreimage(fields map[string]any, preimage map[string]any) map[string]an
635635
// with the binlog Query Events for some statements like GRANT and CREATE USER.
636636
// TODO(johnny): SET STATEMENT is not safe in the general case, and we want to re-visit
637637
// by extracting and ignoring a SET STATEMENT stanza prior to parsing.
638-
var silentIgnoreQueriesRe = regexp.MustCompile(`(?i)^(BEGIN|COMMIT|SAVEPOINT .*|# [^\n]*)$`)
638+
var silentIgnoreQueriesRe = regexp.MustCompile(`(?i)^(BEGIN|COMMIT|ROLLBACK|SAVEPOINT .*|# [^\n]*)$`)
639639
var createDefinerRegex = `CREATE\s*(OR REPLACE){0,1}\s*(ALGORITHM\s*=\s*[^ ]+)*\s*DEFINER`
640640
var ignoreQueriesRe = regexp.MustCompile(`(?i)^(BEGIN|COMMIT|GRANT|REVOKE|CREATE USER|` + createDefinerRegex + `|DROP USER|ALTER USER|DROP PROCEDURE|DROP FUNCTION|DROP TRIGGER|SET STATEMENT|CREATE EVENT|ALTER EVENT|DROP EVENT)`)
641641

0 commit comments

Comments
 (0)