-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/statisticsseverity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
1. Minimal reproduce step (Required)
- Create a table with large TEXT rows (to stress sampling collector memory).
- Set analyze v2 and limit concurrency to increase chance of cleanup reordering:
set @@tidb_analyze_version=2;set @@tidb_build_sampling_stats_concurrency=1;
- Run:
analyze table <tbl> with 1.0 samplerate;
(Optionally) enable internal check/assert to catch the invariant violation:
- build/test with
--tags=intest, or export GO_FAILPOINTS="/enableInternalCheck=return(true)"(with failpoint-enabled build)
2. What did you expect to see? (Required)
Global analyze memory usage (label: LabelForGlobalAnalyzeMemory, metric: analyze/inuse) should never be negative.
3. What did you see instead (Required)
The in-use value can become temporarily negative during Analyze v2 execution (observed via metrics / internal check).
4. Root cause analysis (Optional)
In AnalyzeColumnsExecV2.subBuildWorker, buffered consume/release are deferred in a way that may apply Release before Consume (because multiple defers execute LIFO),
causing transient negative bytesConsumed for the global analyze memory tracker.
5. Proposed fix (Optional)
- Ensure buffered
Consumeis applied before bufferedReleasein worker cleanup. - Add an internal invariant check for
LabelForGlobalAnalyzeMemory. - Add regression test for Analyze v2 to avoid future regressions.
6. Affected versions (Optional)
master
7. Related PR (Optional)
Metadata
Metadata
Assignees
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/statisticsseverity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.