{"record":{"id":"0b6c5b37ca9846c5","repo":"vitessio/vitess","slug":"tablegc-error-while-reading-tables-v","errorCode":null,"errorMessage":"TableGC: error while reading tables: %+v","messagePattern":"TableGC: error while reading tables: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/vt/vttablet/tabletserver/gc/tablegc.go","lineNumber":448,"sourceCode":"// readAndCheckTables is the routine check for which GC tables exist, and which of those need to transition\n// into the next state. The function is non-reentrant, and poses a minimal duration between any two executions.\nfunc (collector *TableGC) readAndCheckTables(\n\tctx context.Context,\n\tdropTablesChan chan<- *gcTable,\n\ttransitionRequestsChan chan<- *transitionRequest,\n) (err error) {\n\tif !collector.readReentranceFlag.CompareAndSwap(0, 1) {\n\t\t// An instance of this function is already running\n\t\treturn nil\n\t}\n\tdefer time.AfterFunc(checkTablesReentryMinInterval, func() {\n\t\tcollector.readReentranceFlag.Store(0)\n\t})\n\n\tlog.Info(\"TableGC: readAndCheckTables\")\n\tgcTables, err := collector.readTables(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"TableGC: error while reading tables: %+v\", err)\n\t}\n\tif err := collector.checkTables(ctx, gcTables, dropTablesChan, transitionRequestsChan); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// readTables reads the list of _vt_% tables from the database\nfunc (collector *TableGC) readTables(ctx context.Context) (gcTables []*gcTable, err error) {\n\tconn, err := collector.pool.Get(ctx, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer conn.Recycle()\n\n\tres, err := conn.Conn.Exec(ctx, sqlShowVtTables, -1, true)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/gc/tablegc.go#L430-L466","documentation":"TableGC's readAndCheckTables step periodically queries INFORMATION_SCHEMA (or the equivalent) to list tables eligible for GC via readTables. If that read fails (query error, context cancellation, tablet shutdown), the error is wrapped with the 'TableGC:' prefix and propagated up through operate.","triggerScenarios":"readTables' schema query fails: MySQL/tablet error, ctx cancelled or timed out, database connection dropped while TableGC's operate loop is running.","commonSituations":"Tablet shutting down while the GC loop fires; network blips between vttablet and MySQL; long-running INFORMATION_SCHEMA queries timing out under load; permission issues with the DBA credentials.","solutions":["Inspect the wrapped error for the root cause; most cases are transient — TableGC retries on the next cycle","Verify MySQL connectivity and DBA credentials used by the GC pool","If caused by shutdown/cancellation, no action needed; ensure graceful tablet drain","Check INFORMATION_SCHEMA availability/performance on the underlying MySQL"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// operate loop already retries; on the caller side:\nif err := collector.readAndCheckTables(ctx); err != nil {\n    log.Warn(\"TableGC cycle skipped\", slog.Any(\"error\", err))\n    // rely on next cycle / verify MySQL health\n}","preventionTips":["Ensure stable MySQL connectivity and DBA credentials","Give the GC loop a generous context timeout","Watch tablet shutdown ordering so GC isn't mid-query during drain"],"tags":["mysql","query-error","table-gc","background-loop"],"backgroundTag":"information-schema-query-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}