{"record":{"id":"864ccdb27f084241","repo":"vitessio/vitess","slug":"no-state-found-for-vdiff-table-s-for-vdiff-id-d","errorCode":null,"errorMessage":"no state found for vdiff table %s for vdiff_id %d on tablet %v","messagePattern":"no state found for vdiff table (.+?) for vdiff_id (.+?) on tablet (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vdiff/table_differ.go","lineNumber":544,"sourceCode":"\t}\n\tdefer dbClient.Close()\n\n\t// We need to continue were we left off when appropriate. This can be an\n\t// auto-retry on error, or a manual retry via the resume command.\n\t// Otherwise the existing state will be empty and we start from scratch.\n\tquery, err := sqlparser.ParseAndBind(sqlGetVDiffTable,\n\t\tsqltypes.Int64BindVariable(td.wd.ct.id),\n\t\tsqltypes.StringBindVariable(td.table.Name),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcs, err := dbClient.ExecuteFetch(query, -1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(cs.Rows) == 0 {\n\t\treturn nil, fmt.Errorf(\"no state found for vdiff table %s for vdiff_id %d on tablet %v\",\n\t\t\ttd.table.Name, td.wd.ct.id, td.wd.ct.vde.thisTablet.Alias)\n\t} else if len(cs.Rows) > 1 {\n\t\treturn nil, fmt.Errorf(\"invalid state found for vdiff table %s (multiple records) for vdiff_id %d on tablet %v\",\n\t\t\ttd.table.Name, td.wd.ct.id, td.wd.ct.vde.thisTablet.Alias)\n\t}\n\tcurState := cs.Named().Row()\n\tmismatch := curState.AsBool(\"mismatch\", false)\n\tdr := &DiffReport{}\n\tif rpt := curState.AsBytes(\"report\", []byte(\"{}\")); json.Valid(rpt) {\n\t\tif err = json.Unmarshal(rpt, dr); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tdr.TableName = td.table.Name\n\n\t// Scope executor goroutines to this single diff attempt, rather\n\t// than surviving until the controller context is canceled.\n\texecCtx, cancelExec := context.WithCancel(ctx)","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vdiff/table_differ.go#L526-L562","documentation":"Before diffing a table, the differ loads the saved state row for (vdiff_id, table) from _vt.vdiff_table. If the query returns zero rows there is no prior state (last PK, counts, etc.) to continue from, so diff aborts with this error.","triggerScenarios":"diff → table state query returns len(cs.Rows)==0 because the _vt.vdiff_table row for this vdiff id/table is missing — deleted manually, or the vdiff record was recreated with a new id while an old controller ran.","commonSituations":"Manual cleanup of _vt.vdiff_table while a vdiff runs; controller retry after the row was removed by 'vdiff delete all'; replica tablet with truncated/missing _vt.vdiff_table data.","solutions":["Delete the vdiff and create a fresh one so state rows are properly inserted: vtctldclient vdiff ... delete all, then create.","Verify rows exist: SELECT * FROM _vt.vdiff_table WHERE vdiff_id=<id> AND table_name='<t>'; on the tablet.","Do not manually remove _vt.vdiff_table rows while a vdiff is active."],"exampleFix":"// before\nDELETE FROM _vt.vdiff_table WHERE vdiff_id=7; // while vdiff 7 running\n// after\nvtctldclient vdiff --keyspace ks --workflow wf delete all\nvtctldclient vdiff --keyspace ks --workflow wf create // reinserts state","handlingStrategy":"validation","validationCode":"var n int\n_ := db.QueryRow(\"SELECT COUNT(*) FROM _vt.vdiff_table WHERE vdiff_id=? AND table_name=?\", id, table).Scan(&n)\nif n == 0 { recreateVDiff() }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"no state found for vdiff table\") {\n  // state row missing; delete all + create a fresh vdiff\n  deleteAllVDiffs(workflow)\n  createVDiff(keyspace, workflow)\n}","preventionTips":["Never DELETE from _vt.vdiff_table while a vdiff is active.","Use 'vdiff delete all' for cleanup instead of manual row surgery.","Verify _vt.vdiff_table rows exist after restoring a tablet.","Don't mix vdiff ids from previous runs when resuming."],"tags":["vdiff","missing-record","state","mysql"],"backgroundTag":"vdiff-missing-table-state","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}