{"record":{"id":"3f17319f0d4ee739","repo":"pingcap/tidb","slug":"out-of-global-analyze-memory-limit","errorCode":null,"errorMessage":"Out Of Global Analyze Memory Limit!","messagePattern":"Out Of Global Analyze Memory Limit!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/executor/select.go","lineNumber":182,"sourceCode":"}\n\n// Action panics when storage usage exceeds storage quota.\nfunc (a *globalPanicOnExceed) Action(t *memory.Tracker) {\n\ta.mutex.Lock()\n\tdefer a.mutex.Unlock()\n\tmsg := \"\"\n\tswitch t.Label() {\n\tcase memory.LabelForGlobalStorage:\n\t\tmsg = globalPanicStorageExceed\n\tcase memory.LabelForGlobalMemory:\n\t\tmsg = globalPanicMemoryExceed\n\tcase memory.LabelForGlobalAnalyzeMemory:\n\t\tmsg = globalPanicAnalyzeMemoryExceed\n\tdefault:\n\t\tmsg = \"Out of Unknown Resource Quota!\"\n\t}\n\t// TODO(hawkingrei): should return error instead.\n\tpanic(msg)\n}\n\n// GetPriority get the priority of the Action\nfunc (*globalPanicOnExceed) GetPriority() int64 {\n\treturn memory.DefPanicPriority\n}\n\n// SelectLockExec represents a select lock executor.\n// It is built from the \"SELECT .. FOR UPDATE\" or the \"SELECT .. LOCK IN SHARE MODE\" statement.\n// For \"SELECT .. FOR UPDATE\" statement, it locks every row key from source Executor.\n// After the execution, the keys are buffered in transaction, and will be sent to KV\n// when doing commit. If there is any key already locked by another transaction,\n// the transaction will rollback and retry.\ntype SelectLockExec struct {\n\texec.BaseExecutor\n\n\tLock *ast.SelectLockInfo\n\tkeys []kv.Key","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/pingcap/tidb/blob/d01f9615c13e02dfa75922745640dec9d81b802e/pkg/executor/select.go#L164-L200","documentation":"Fired by the same globalPanicOnExceed action in pkg/executor/select.go, but for the tracker labeled LabelForGlobalAnalyzeMemory: TiDB's server-wide quota on memory consumed by statistics gathering (ANALYZE). When concurrent ANALYZE jobs together exceed that quota, TiDB panics the analyze task with 'Out Of Global Analyze Memory Limit!' rather than letting ANALYZE destabilize the server.","triggerScenarios":"Running ANALYZE (full or with high sampling) on very large tables, or several ANALYZE jobs in parallel, such that total analyze memory passes the global analyze quota; auto-analyze kicking in on big tables concurrently with manual ANALYZE.","commonSituations":"After ingesting a huge dataset and running ANALYZE TABLE ... ALL COLUMNS with default (near-full) sampling; enabling auto-analyze on many large tables at once; upgrading to a TiDB that added the global analyze-memory quota so previously-tolerated analyze workloads now panic; an instance already near its memory limit so the analyze quota is small.","solutions":["Reduce analyze scope per run: ANALYZE with sample rate (ANALYZE TABLE t WITH 0.1 SAMPLERATE) or fewer columns instead of full ANALYZE.","Serialize ANALYZE jobs (disable auto-analyze temporarily: SET GLOBAL tidb_enable_auto_analyze = OFF) so they do not stack on the quota.","Raise the analyze/global memory quota (memory_usage_limit / relevant tidb_mem_quota_analyze settings) if the hardware allows.","Run heavy ANALYZE off-peak, then re-enable auto-analyze."],"exampleFix":"-- before: full analyze on a huge table trips the global analyze quota\nANALYZE TABLE orders;\n\n-- after: sample instead of full scan\nANALYZE TABLE orders WITH 0.05 SAMPLERATE;\n-- or restrict columns\nANALYZE TABLE orders INDEX o_custkey_idx;","handlingStrategy":"validation","validationCode":"-- check analyze memory headroom and table size before launching ANALYZE\nSELECT table_name, ROUND((data_length+index_length)/1024/1024) AS mb\nFROM information_schema.tables\nWHERE table_schema = 'mydb' ORDER BY mb DESC;\n\nSET GLOBAL tidb_enable_auto_analyze = OFF; -- serialize with manual analyze first","typeGuard":null,"tryCatchPattern":"-- the panic reaches the client as error 1105 on the ANALYZE statement;\n-- retry once with a smaller sample rate\nANALYZE TABLE t; -- on 'Out Of Global Analyze Memory Limit!': ANALYZE TABLE t WITH 0.05 SAMPLERATE;","preventionTips":["Always sample large tables (WITH n SAMPLERATE) instead of full ANALYZE.","Run ANALYZE jobs sequentially; disable auto-analyze during bulk loads.","Budget the analyze quota against total instance memory when sizing."],"tags":["tidb","analyze","memory","quota","panic"],"backgroundTag":null,"analyzedSha":"d01f9615c13e02dfa75922745640dec9d81b802e","analyzedAt":"2026-08-15T12:19:33.324Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}