{"record":{"id":"1145a3fc1494de13","repo":"vitessio/vitess","slug":"no-vdiff-found-for-id-d-on-tablet-v","errorCode":null,"errorMessage":"no vdiff found for id %d on tablet %v","messagePattern":"no vdiff found for id (.+?) on tablet (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vdiff/engine.go","lineNumber":332,"sourceCode":"\t\treturn nil, err\n\t}\n\tif len(qr.Rows) == 0 {\n\t\treturn nil, nil\n\t}\n\treturn qr, nil\n}\n\nfunc (vde *Engine) getVDiffByID(ctx context.Context, dbClient binlogplayer.DBClient, id int64) (*sqltypes.Result, error) {\n\tquery, err := sqlparser.ParseAndBind(sqlGetVDiffByID, sqltypes.Int64BindVariable(id), sqltypes.StringBindVariable(vde.dbName))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tqr, err := dbClient.ExecuteFetch(query, -1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(qr.Rows) != 1 {\n\t\treturn nil, fmt.Errorf(\"no vdiff found for id %d on tablet %v\",\n\t\t\tid, vde.thisTablet.Alias)\n\t}\n\treturn qr, nil\n}\n\nfunc (vde *Engine) retryVDiffs(ctx context.Context) error {\n\tvde.mu.Lock()\n\tdefer vde.mu.Unlock()\n\tdbClient := vde.dbClientFactoryFiltered()\n\tif err := dbClient.Connect(); err != nil {\n\t\treturn err\n\t}\n\tdefer dbClient.Close()\n\n\tqr, err := vde.getVDiffsToRetry(ctx, dbClient)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vdiff/engine.go#L314-L350","documentation":"getVDiffByID fetches exactly one _vt.vdiff row by primary-key id; if the query returns any row count other than 1 (i.e. zero, since id is a PK), it reports that no vdiff exists for that id on this tablet. Callers (create/resume handling, run loop) treat this as a missing-record condition.","triggerScenarios":"handleCreateResumeAction or run calls getVDiffByID with an id that has no row in this tablet's local _vt.vdiff table — e.g. the record was deleted concurrently or the tablet's local table was recreated.","commonSituations":"A 'vdiff delete all' racing with a create/resume; targeting a replica tablet that was recently rebuilt/restored and lost _vt.vdiff rows; resuming after someone manually cleaned the table.","solutions":["Re-run the create/resume so a fresh vdiff record is inserted on the tablet.","Check the table: SELECT * FROM _vt.vdiff WHERE id=<id>; on the target tablet to confirm absence.","Avoid racing delete and show/resume operations on the same workflow."],"exampleFix":"// before\nct, _ := vde.getVDiffByID(ctx, dbClient, staleID)\n// after (operator flow)\nvtctldclient vdiff --keyspace ks --workflow wf delete all\nvtctldclient vdiff --keyspace ks --workflow wf create // fresh id","handlingStrategy":"validation","validationCode":"var n int\n_ := db.QueryRow(\"SELECT COUNT(*) FROM _vt.vdiff WHERE id=?\", id).Scan(&n)\nif n != 1 { recreateVDiff() } // record missing on this tablet","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"no vdiff found for id\") {\n  // record was deleted or tablet lost state; start a fresh vdiff\n  createVDiff(keyspace, workflow)\n}","preventionTips":["Don't run vdiff delete concurrently with show/resume.","After restoring a tablet, verify _vt.vdiff contents before resuming.","Re-create rather than resume when a vdiff id is reported missing.","Track vdiff ids per workflow in automation to avoid stale ids."],"tags":["vdiff","missing-record","mysql","race"],"backgroundTag":"vdiff-record-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}