{"record":{"id":"6e33caf8dc92b010","repo":"vitessio/vitess","slug":"failed-to-check-innodb-adaptive-hash-index-setting","errorCode":null,"errorMessage":"failed to check innodb_adaptive_hash_index setting: unexpected result","messagePattern":"failed to check innodb_adaptive_hash_index setting: unexpected result","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletserver/gc/tablegc.go","lineNumber":243,"sourceCode":"\t\treturn lifecycleStates, nil\n\t}\n\n\tserverSupportsFastDrops, err := conn.SupportsCapability(capabilities.FastDropTableFlavorCapability)\n\tif err != nil {\n\t\treturn lifecycleStates, err\n\t}\n\tif !serverSupportsFastDrops {\n\t\treturn lifecycleStates, nil\n\t}\n\n\t// Unfortunately you can still encounter problems if the Adaptive Hash Indexes are enabled: https://bugs.mysql.com/bug.php?id=113312\n\t// So if AHI is enabled, we cannot safely skip PURGE and EVAC even on MySQL versions that support fast DROP TABLE.\n\tres, err := conn.ExecuteFetch(\"SELECT variable_value FROM performance_schema.global_variables WHERE variable_name = 'innodb_adaptive_hash_index'\", 1, false)\n\tif err != nil {\n\t\treturn nil, vterrors.Wrap(err, \"failed to check innodb_adaptive_hash_index setting\")\n\t}\n\tif res == nil || len(res.Rows) == 0 || len(res.Rows[0]) == 0 {\n\t\treturn nil, errors.New(\"failed to check innodb_adaptive_hash_index setting: unexpected result\")\n\t}\n\tif strings.ToLower(res.Rows[0][0].ToString()) == \"on\" {\n\t\treturn lifecycleStates, nil\n\t}\n\n\tupdated := make(map[schema.TableGCState]bool, len(lifecycleStates))\n\tmaps.Copy(updated, lifecycleStates)\n\tdelete(updated, schema.PurgeTableGCState)\n\tdelete(updated, schema.EvacTableGCState)\n\treturn updated, nil\n}\n\n// Close frees resources\nfunc (collector *TableGC) Close() {\n\tlog.Info(\"TableGC - started execution of Close. Acquiring initMutex lock\")\n\tcollector.stateMutex.Lock()\n\tdefer collector.stateMutex.Unlock()\n\tlog.Info(\"TableGC - acquired lock\")","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/gc/tablegc.go#L225-L261","documentation":"tablegc's adjustLifecycleForFastDrops queries performance_schema.global_variables for innodb_adaptive_hash_index to decide whether fast DROP TABLE can be used. When the query succeeds but returns no rows/columns, it cannot determine the AHI state and fails with this error rather than guessing and potentially skipping PURGE/EVAC unsafely.","triggerScenarios":"SELECT variable_value FROM performance_schema.global_variables WHERE variable_name='innodb_adaptive_hash_index' returns nil result, zero rows, or a zero-column row — e.g. performance_schema disabled or the variable absent.","commonSituations":"performance_schema disabled in target mysqld config (performance_schema=OFF); MySQL versions where the variable doesn't exist in global_variables; hardened MySQL setups restricting performance_schema access for the vttablet user.","solutions":["Enable performance_schema on the target mysqld (remove performance_schema=OFF) and restart mysqld","Grant the vttablet MySQL user SELECT on performance_schema.global_variables","If the MySQL flavor/version lacks innodb_adaptive_hash_index, upgrade to a supported version or let tablegc fall back by ensuring the variable is present"],"exampleFix":"// before (my.cnf)\n[mysqld]\nperformance_schema=OFF\n// after\n[mysqld]\nperformance_schema=ON","handlingStrategy":"validation","validationCode":"// Verify performance_schema exposes the variable before enabling tablegc fast drops\nqr, err := conn.ExecuteFetch(\"SELECT variable_value FROM performance_schema.global_variables WHERE variable_name = 'innodb_adaptive_hash_index'\", 1, false)\nif err != nil || len(qr.Rows) == 0 {\n    return fmt.Errorf(\"performance_schema disabled or variable unavailable\")\n}","typeGuard":null,"tryCatchPattern":"if err := gc.Open(ctx); err != nil {\n    if strings.Contains(err.Error(), \"innodb_adaptive_hash_index\") {\n        // enable performance_schema / fix grants, then reopen\n        return fmt.Errorf(\"fix mysqld config (performance_schema=ON, grants) and retry\")\n    }\n    return err\n}","preventionTips":["Keep performance_schema=ON in all mysqld configs used by Vitess","Grant vttablet SELECT on performance_schema.global_variables","Validate mysqld config in CI before rolling out"],"tags":["tablegc","mysql","performance-schema","gc"],"backgroundTag":"unexpected-query-result","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}