{"record":{"id":"c04826545730eb98","repo":"vitessio/vitess","slug":"internal-error-vplayer-is-in-a-transaction-on-eve","errorCode":null,"errorMessage":"internal error: vplayer is in a transaction on event: %v","messagePattern":"internal error: vplayer is in a transaction on event: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/vplayer.go","lineNumber":790,"sourceCode":"\t\t\t}\n\t\t\tif err := vp.applyStmtEvent(ctx, event); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\tcase binlogdatapb.VEventType_ROW:\n\t\t// This player is configured for row based replication\n\t\tif err := vp.vr.dbClient.Begin(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := vp.applyRowEvent(ctx, event.RowEvent); err != nil {\n\t\t\tlog.Info(\"Error applying row event: \" + err.Error())\n\t\t\treturn err\n\t\t}\n\tcase binlogdatapb.VEventType_OTHER:\n\t\tif vp.vr.dbClient.InTransaction {\n\t\t\t// Unreachable\n\t\t\tlog.Error(fmt.Sprintf(\"internal error: vplayer is in a transaction on event: %v\", event))\n\t\t\treturn fmt.Errorf(\"internal error: vplayer is in a transaction on event: %v\", event)\n\t\t}\n\t\t// Just update the position.\n\t\tposReached, err := vp.updatePos(ctx, event.Timestamp)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif posReached {\n\t\t\treturn io.EOF\n\t\t}\n\tcase binlogdatapb.VEventType_DDL:\n\t\tif vp.vr.dbClient.InTransaction {\n\t\t\t// Unreachable\n\t\t\tlog.Error(fmt.Sprintf(\"internal error: vplayer is in a transaction on event: %v\", event))\n\t\t\treturn fmt.Errorf(\"internal error: vplayer is in a transaction on event: %v\", event)\n\t\t}\n\t\tvp.vr.stats.DDLEventActions.Add(vp.vr.source.OnDdl.String(), 1) // Record the DDL handling\n\t\tswitch vp.vr.source.OnDdl {\n\t\tcase binlogdatapb.OnDDLAction_IGNORE:","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/vplayer.go#L772-L808","documentation":"A defensive, marked-unreachable error: when an OTHER-type vstream event arrives, vplayer requires that it is not inside a database transaction, because OTHER events only update the stored position and must not commit mid-transaction state. If dbClient.InTransaction is true at that point, internal transaction bookkeeping is broken, so it logs and returns this internal error.","triggerScenarios":"applyEvent receives a VEventType_OTHER event while vp.vr.dbClient.InTransaction is true — meaning a previous row-event transaction was left open instead of being committed/rolled back before the non-row event.","commonSituations":"Upstream bug where transaction commit was skipped on an error path; partial event application interrupted without rollback; custom patched builds altering the event loop; true internal invariant violation after an earlier swallowed error.","solutions":["Treat as a Vitess bug: file an issue with the tablet logs, workflow name, and the event details from the 'internal error' log line","Check preceding log lines for a failed commit/rollback that left the transaction open; identify the original error","Restart the vreplication workflow (or the tablet) to reset transaction state and let it re-apply from the last saved position","Verify you are on a supported Vitess release; upgrade if a fix for the leaked transaction exists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"internal error: vplayer is in a transaction\") {\n    // This is an invariant violation: capture logs, restart the workflow,\n    // and file a Vitess issue with the event and preceding errors\n}","preventionTips":["Don't patch the vplayer event loop without preserving commit-before-non-row-event ordering","Ensure no error path leaves dbClient with an open transaction (always commit/rollback on error)","Run supported Vitess releases; this error signals an upstream bug","Keep tablet logs around to diagnose the original leaked-transaction cause"],"tags":["vreplication","internal-error","transaction-state","vplayer"],"backgroundTag":"vplayer-open-transaction-on-event","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}