{"record":{"id":"12bd2138c206c650","repo":"vitessio/vitess","slug":"error-in-processing-binlog-event-v","errorCode":null,"errorMessage":"error in processing binlog event %v","messagePattern":"error in processing binlog event (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlogplayer/binlog_player.go","lineNumber":421,"sourceCode":"\t\t// contexts could be wrapped as regular errors.\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\t\tdefault:\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error received from Stream %v\", err)\n\t\t}\n\n\t\t// process the transaction\n\t\tfor {\n\t\t\tok, err = blp.processTransaction(response)\n\t\t\tif err != nil {\n\t\t\t\tlog.Info(fmt.Sprintf(\"transaction failed: %v\", err))\n\t\t\t\tfor _, stmt := range response.Statements {\n\t\t\t\t\tlog.Info(fmt.Sprintf(\"statement: %q\", stmt.Sql))\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"error in processing binlog event %v\", err)\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\tif !blp.stopPosition.IsZero() {\n\t\t\t\t\tif blp.position.AtLeast(blp.stopPosition) {\n\t\t\t\t\t\tmsg := \"Reached stopping position, done playing logs\"\n\t\t\t\t\t\tlog.Info(msg)\n\t\t\t\t\t\tif err := blp.setVReplicationState(binlogdatapb.VReplicationWorkflowState_Stopped, msg); err != nil {\n\t\t\t\t\t\t\tlog.Error(fmt.Sprintf(\"Error writing stop state: %v\", err))\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tlog.Info(fmt.Sprintf(\"Retrying txn in %v.\", blp.deadlockRetry))\n\t\t\ttime.Sleep(blp.deadlockRetry)\n\t\t}\n\t}","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlogplayer/binlog_player.go#L403-L439","documentation":"Thrown by applyEvents when blp.processTransaction fails to apply a received binlog transaction to the target. The failed transaction's statements are logged for diagnosis and the error bubbles up so the stream restarts from the last committed recovery position.","triggerScenarios":"processTransaction returns err: BEGIN fails, SET charset fails, statement exec fails (e.g. duplicate key, missing table, SQL mode difference, data type mismatch), recovery-position write fails, or COMMIT fails.","commonSituations":"Target schema out of sync with source (missing column/table), duplicate rows causing ER_DUP_ENTRY after a partial replay, MySQL sql_mode/collation differences, or a target under external writes conflicting with replayed rows.","solutions":["Read the wrapped inner error and the logged `statement:` lines to see which SQL failed and why.","Fix the target schema to match source (apply migration that diverged).","Resolve data conflicts: for duplicate-key errors, either delete the conflicting row or verify the recovery position and let the player reapply.","Check that no other writer is mutating the replicated tables on the target during the stream.","Restart the stream after fixing; it resumes from the last written recovery position."],"exampleFix":"// before: target missing column, statement fails\n//   ALTER TABLE t ADD COLUMN c VARCHAR(10);  -- run on target\n// after: schema matches, replay proceeds\n//   (stream restarts and processTransaction succeeds)","handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm target schema matches source for replicated tables\nfor _, t := range tables {\n    src := showCreateTable(sourceDB, t)\n    tgt := showCreateTable(targetDB, t)\n    if normalize(src) != normalize(tgt) {\n        return fmt.Errorf(\"schema drift on %s: fix before starting stream\", t)\n    }\n}","typeGuard":null,"tryCatchPattern":"// capture failed SQL from logs and the inner error for triage\nerr := binlogplayer.ApplyBinlogEvents(ctx, blp)\nif err != nil && strings.Contains(err.Error(), \"error in processing binlog event\") {\n    log.Errorf(\"replay failed: %v — check 'statement:' log lines for the failing SQL\", err)\n    // fix schema/data, then restart stream; it resumes from recovery position\n}","preventionTips":["Keep target schema in lockstep with source migrations during resharding","Ensure no external writers touch replicated tables on the target","Verify MySQL sql_mode and collations match between source and target","Run schema validation (vtctldclient schema compare) before starting workflows"],"tags":["binlog-replay","mysql","schema-mismatch","vreplication"],"backgroundTag":"binlog-transaction-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}