{"record":{"id":"ba983d50328fdd8e","repo":"vitessio/vitess","slug":"forgetinstance-tablet-v-not-found","errorCode":null,"errorMessage":"ForgetInstance(): tablet %+v not found","messagePattern":"ForgetInstance\\(\\): tablet %\\+v not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/vt/vtorc/inst/instance_dao.go","lineNumber":1198,"sourceCode":"\t\t\tdatabase_instance\n\t\tWHERE\n\t\t\talias = ?`,\n\t\ttabletAliasString,\n\t)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\treturn err\n\t}\n\t// Get the number of rows affected. If they are zero, then we tried to forget an instance that doesn't exist.\n\trows, err := sqlResult.RowsAffected()\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\treturn err\n\t}\n\tif rows == 0 {\n\t\terrMsg := fmt.Sprintf(\"ForgetInstance(): tablet %+v not found\", tabletAliasString)\n\t\tlog.Error(errMsg)\n\t\treturn errors.New(errMsg)\n\t}\n\t_ = AuditOperation(\"forget\", tabletAlias, \"\")\n\treturn nil\n}\n\n// ForgetLongUnseenInstances will remove entries of all instances that have long since been last seen.\nfunc ForgetLongUnseenInstances() error {\n\tsqlResult, err := db.ExecVTOrc(`DELETE\n\t\tFROM database_instance\n\t\tWHERE\n\t\t\tlast_seen < DATETIME('now', PRINTF('-%d HOUR', ?))\n\t\t`,\n\t\tconfig.UnseenInstanceForgetHours,\n\t)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\treturn err\n\t}","sourceCodeStart":1180,"sourceCodeEnd":1216,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtorc/inst/instance_dao.go#L1180-L1216","documentation":"ForgetInstance deletes the tablet row from the vtorc database; when the DELETE affects zero rows, the tablet does not exist and this error is returned. It confirms the requested tablet alias was already forgotten or never discovered.","triggerScenarios":"Calling ForgetInstance with an alias that has no row in the vtorc database — e.g., forgetting twice, or forgetting a tablet vtorc never discovered.","commonSituations":"Double invocation of forget in recovery scripts; racing with refreshTablets which already pruned the stale tablet; typo in cell/uid components of the alias.","solutions":["Treat it as benign if the goal is 'tablet must not be tracked' — check and ignore, or use a helper that tolerates not-found.","Verify the alias (cell + uid) is correct with topoproto.TabletAliasString.","Query the vtorc database_instance table first to confirm the tablet is present before forgetting."],"exampleFix":"// before\nif err := inst.ForgetInstance(alias); err != nil { return err }\n// after\nif err := inst.ForgetInstance(alias); err != nil && !strings.Contains(err.Error(), \"not found\") {\n    return err\n}","handlingStrategy":"try-catch","validationCode":"exists, err := instanceExistsInDb(alias)\nif err == nil && !exists {\n    return nil // already forgotten\n}","typeGuard":null,"tryCatchPattern":"err := inst.ForgetInstance(alias)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    return nil // idempotent: nothing to forget\n} else if err != nil { return err }","preventionTips":["Design forget operations to be idempotent and tolerate not-found.","Confirm the tablet exists in the vtorc database before forgetting.","Avoid double-invoking forget in recovery/cleanup scripts."],"tags":["vtorc","forget-instance","not-found","idempotency"],"backgroundTag":"entity-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}