Repository navigation
fix(memory): coordinate process-wide RSS recovery - #33039
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 0fe9c6754477986c1f8dcab79a8e1a11c4240724
Assessment: request_changes
One process-wide controller removes duplicate cache walks while preserving separate flush and workspace admission policies. Two defects remain. An in-flight cache callback can hold shutdown past the eviction deadline, and mixing observations can trigger an unnecessary synchronous GC.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
-
P2
pkg/common/rscthrottler/rss_pressure.go:157: The last RSS source closes while a registered memory cache is still running a synchronous eviction callback.
Impact: CN or standalone engine shutdown waits for the callback even after the eviction deadline. The same wait holds the lifecycle lock and blocks new reporters from attaching.
Evidence: The fileservice deadline check runs between caches. Once a cache starts eviction, its removal callbacks run synchronously before the worker can return. A probe using the real MemCache path confirmed that Close stayed blocked after the deadline and completed when the callback was released. Bound the work that shutdown joins while preserving ownership of callbacks already in flight. See pressure-probes.log and checks/1795257528088810527-2.json. -
P2
pkg/common/rscthrottler/rss_pressure.go:217: One reporter records a low reservation during a healthy sample. Within ten seconds, the other reporter observes pressure with its own visible memory above the 70% threshold.
Impact: The controller can combine the earlier reservation with the new RSS and live bytes, cross the threshold artificially, and force a synchronous GC on the refreshing caller.
Evidence: The candidate produced one immediate free for a report with 655 visible bytes out of 900 RSS after borrowing the earlier zero reservation. The pinned baseline produced zero immediate frees for the same sequence. Evaluate the immediate GC threshold from one complete report and keep the shared cooldown. See pressure-probes.log and baseline-reservation.log.
Validation:
-
Verified the frozen head, patch, clean checkout, and retained native build inputs. Private /tmp and loopback preflight passed.
-
The full rscthrottler package and focused fileservice tests passed under the race detector. Each of the three controller tests and the fileservice eviction test passed 100 race-instrumented repetitions.
-
Focused CN and disttae lifecycle tests passed. See owner-lifecycle-tests.log and checks/1795257691731022330-2.json.
-
The controller probes reproduced both findings. The baseline reservation control passed with zero immediate frees. See checks/1795257528088810527-2.json and checks/1795257583055704787-2.json.
Limitations:
-
The shutdown probe injected a delay in a real cache callback. Production shutdown latency remains unmeasured.
-
The author's SQL smoke stayed below the RSS trigger. Frozen shared build, x86 unit tests, and static analysis were in progress.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 9927f7ee707f0a6783bc40ddf0737cbcf317f6dd
Assessment: request_changes
One process-wide controller removes duplicate eviction work while preserving separate flush and workspace admission. This revision resolves the earlier shutdown wait and mixed-visibility GC findings. A transient cgroup read failure can still override another reporter’s valid pressure observation.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
- P2
pkg/common/rscthrottler/resource_throttler.go:185: CN flush establishes hard pressure from a valid RSS and cgroup ceiling. Workspace then samples the same high RSS, but its cgroup lookup fails and host RAM is much larger than the cgroup ceiling.
Impact: The failed lookup clears the shared 50% cache target and cancels the active eviction walk while RSS is still near the cgroup limit. Ordinary cache admission resumes until another valid pressure report arrives.
Evidence: The exact-head fault probe observed hard pressure changing to none, the incomplete sample advancing lastSample, and the active walk receiving context.Canceled. The pinned baseline control retained the CN’s 50% target through the equivalent workspace fallback. Require a valid ceiling for shared pressure updates, preserve host fallback when the platform has no cgroup limit, and leave the prior lease in place on transient lookup errors.
Validation:
-
Verified the frozen head, merge base, complete patch, clean checkout, and native inputs. The isolation preflight and diff checks passed. Reconciled all five discussion entries.
-
The full rscthrottler package and focused fileservice, CN, and disttae tests passed under the race detector. The detach, visibility, RSS ordering, and real cache-close tests each passed 100 race-instrumented runs.
-
The candidate fault probe reproduced the lease and eviction regression. The pinned baseline control passed. See pressure-error-probe.log and baseline-pressure-control.log with receipts 1795259879859487707-2.json and 1795260025587036362-2.json.
Limitations:
-
The full local fileservice race run timed out during the MinIO invalid-write-length test after the changed memory-cache tests passed. See fileservice-package-race.jsonl and receipt 1795260215281751053-2.json.
-
The author’s SQL smoke stayed below the RSS pressure trigger. Production recovery latency and OOM outcomes remain unmeasured.
16f4511 to
29e6384
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 29e6384c1315e6d63b90bad5d8209b7d0713a747
Assessment: request_changes
One process-wide lease and eviction worker remove duplicate recovery while preserving independent flush and workspace admission. The current head resolves the earlier mount-detach issue. Two recovery paths still need changes. An unreadable ancestor can suppress pressure already established by a finite child limit, and an elapsed eviction deadline can leave an admitted batch without its native arena purge.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
-
P2
pkg/common/rscthrottler/cgroup_limit_linux.go:101: The cgroup v2 child limit is readable and already puts RSS above the hard threshold, but a mount masks only an ancestor's memory.max. The process can remain in this state across refreshes.
Impact: Both reporters discard the valid finite bound, so the shared controller fails to establish a cache target or schedule recovery even when the readable limit already proves hard pressure. An existing target can also expire under sustained pressure while the ancestor remains unreadable.
Evidence: The race probe kept RSS at 950 bytes and the finite child limit at 1,000. It installed a 50% target with the ancestor visible and none after masking only the ancestor file. The hierarchy walk dropped the child bound, and resource_throttler.go:214 discards numeric bounds on resolver errors. Preserve a verified finite upper bound with incomplete coverage and allow it to establish pressure. Keep full coverage mandatory for relaxation. See pressure-probes-race.jsonl and checks/1795285477141194970-2.json. -
P3
pkg/fileservice/mem_cache.go:909: The ten-second pressure eviction budget elapses after a live memory cache starts a FIFO batch and before the batch finishes.
Impact: The admitted removals finish and release their cache references. The new deadline check then skips the explicit jemalloc purge, so unused native pages can stay resident despite a drop in FIFO usage. The process-wide eviction walk returns without completing that part of RSS recovery.
Evidence: The race probe advanced the deadline from the first removal callback. All 64 admitted callbacks finished, the next entry stayed in cache, and the purge counter was zero. The live-deadline control purged once, and the merge base called reclaimAllocator after EvictToTarget returned. Keep the deadline check at batch admission and retain a cleanup owner for the native pages from work already admitted. Retired caches should continue to rely on their close path. See pressure-probes-race.jsonl and checks/1795285477141194970-2.json.
Validation:
-
Verified the frozen patch and clean checkout, private /tmp and loopback, and native build inputs. See source-audit.log, preflight.log and native-input-check.log with receipts 1795285432467001753-3.json, 1795285067844643063-2.json and 1795285068545247680-2.json.
-
The complete rscthrottler and s3fifo packages passed under the race detector. The focused CN and disttae lifecycle selections also passed. See core-race.jsonl and owners-race.jsonl with receipts 1795285156554715876-2.json and 1795285509044793333-2.json.
-
The two review probes reproduced the findings under the race detector. Three committed fileservice pressure tests passed in that same run, including the cancellation, close, and allocator purge controls. See pressure-probes-race.jsonl and receipt 1795285477141194970-2.json.
Limitations:
-
The cgroup probe used Linux mountinfo and filesystem fixtures. The expiry probe controlled the deadline and measured purge calls. Production RSS, recovery latency and OOM outcomes were not measured.
-
The author’s CTAS and INSERT SELECT runs stayed below the recovery trigger. Local service and fileservice validation was focused, and the frozen full CI runs were still in progress.
Share pressure state and cooldowns across CN flush and workspace admission. Bound eviction to the current pressure generation and retire it with the last reporting source. Keep component reservation policies independent.
29e6384 to
c0dfe15
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: c0dfe15b758fe6504a563825b6ca10736c0f6abc
Assessment: approve
One process-wide controller coordinates RSS recovery while CN flush and workspace keep independent admission policies. The revision resolves both prior findings. A verified finite cgroup limit can trigger recovery across an unreadable ancestor, and an admitted eviction batch completes its callbacks and allocator purge after the deadline.
Model: gpt-6.2-sol / xhigh
Session: 01a1feb0-0427-7772-9d89-786820ec84a5 · slot 1 · generation 2
Validation:
-
Reviewed the complete 23-file delta and reconciled all 19 discussion entries in
discussion-assessment.json. -
The full rscthrottler and s3fifo suites and the focused MemCache tests passed under race. See
core-race.jsonlandfileservice-race.jsonl. -
The finite-bound, ancestry, FIFO cancellation, and allocator purge regressions each passed 100 race-instrumented runs.
-
Focused CN and disttae lifecycle tests passed under race.
TestIssue29492MultiCNCancellationCleanuppassed for both text and binary protocols. Seeowners-race.jsonl. -
Isolation preflight, native build and provenance, frozen-source checks, and
git diff --checkpassed.validation-audit.logmatches each check to its retained log and receipt.
Limitations:
-
Cgroup visibility and deadline transitions were exercised with fixtures. Production recovery latency and OOM outcomes remain unmeasured. The supplied SQL throughput runs stayed below the RSS trigger.
-
The frozen shared build, unit tests, static analysis, and coverage checks were still in progress.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Reviewed #33039 at head c0dfe15 against origin/main (23 files, +2283/-647), together with all nine prior PR reviews, the eleven issue comments, and the inline review comments (there are none; the discussion is the author's automated review loop). The PR replaces the two independent RSS scavenging state machines of the cnservice CNFlushS3 throttler and the disttae Workspace throttler with one process-wide rssPressureController that owns pressure hysteresis, the cache pressure-target lease, a single serialized eviction worker, and the GC cooldown, while each throttler keeps its own admission policy and local ceiling. Every finding from the prior review rounds is verifiably fixed at this head: RSS samples are ordered at capture through sampleMu with lastRSSCapture and lastSample guards so a slow ceiling lookup cannot override a newer observation; a failed or partial cgroup read keeps the existing lease instead of clearing shared pressure; alternate, stacked, and partially covered cgroup views are resolved per level, the minimum verified finite v2 bound is retained across unreadable levels, and relaxation requires a reading whose root covers the lease ancestry, with coverage published before blocking hierarchy reads; the one-batch FIFO contract completes already admitted callbacks, the cache purges its allocator exactly once for committed removals or idle releases, and deadline admission is checked at walk, cache, idle-drain, and batch boundaries; shutdown and last-source detach no longer join an in-flight cache callback, and both cnservice NewService and disttae New detach the reporter when construction fails (verified through the existing constructed and deferred Close patterns). Independent first-principles checks of lock ordering, lease TTL renewal, deadline selection, cross-source free deduplication, owner-scoped target set and clear semantics, v1 and v2 resolver edge cases, and cache retirement found no remaining defect. Verification: the full pkg/fileservice/s3fifo package passed locally on go1.27.1 (34 of 34 tests, -v log saved), including the new TestPressureEvictionFinishesAdmittedBatch and TestEvictToStopsOnCancel; gofmt and go vet are clean on the runnable subset and the linux-only files parse cleanly. Limitation: pkg/common/rscthrottler, pkg/fileservice, pkg/cnservice, and pkg/vm/engine/disttae cannot be compiled or tested locally because the checkout's cgo third-party headers (jemalloc.h, usearch.h, xxhash.h, roaring.h from the documented make cgo-native-thirdparties-internal target) are not built and building them is out of review scope; CGO_ENABLED=0 also fails since mpool requires malloc.SimpleCAllocator, so for those packages the analysis rests on static review, the new unit tests, and the PR's reported full race UT coverage on this head. Cgroup view transitions are exercised through fixtures in tests, and production recovery latency and OOM outcomes remain unmeasured, as the PR description itself notes.
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32287
What this PR does / why we need it:
CN flush and workspace throttlers observe the same process RSS. Each previously maintained its own pressure state and could trigger a fileservice cache walk and process-wide GC for the same pressure event.
Give hysteresis, the cache target lease, and recovery cooldowns one process-wide owner. Either throttler can publish a complete fresh sample, including standalone disttae. Each throttler retains its component admission policy. RSS samples are ordered at capture so a slower ceiling lookup cannot replace a newer observation.
Keep one on-demand eviction worker and one pending action. Pressure transitions and last-source detach cancel obsolete work. The worker completes callbacks and releases values already removed. Cancellation and elapsed deadlines prevent a new pressure batch from starting, including during capacity lookup and FIFO admission. Share one percentage target calculation per cache between logging and eviction.
Read cgroup limits from process membership and reachable mount views. The coverage required to relax v2 pressure belongs to the live lease. Detaching a wide view cannot make a leaf-only reading complete. Fresh narrow readings can prove pressure, while relaxation requires equivalent ancestry coverage. An explicit v2 unlimited result still carries its coverage when normalized to host memory. A genuine host-only or v1 hierarchical reading remains authoritative.
Publish the known v2 ancestry before reading hierarchy files. A stale RSS capture or failed file read can supply scope information without renewing the lease or canceling eviction. Retain a single logical path, independent of mount IDs and mountpoints. If the process moves between incomparable subtrees during a lease, recovery can wait for broader evidence or the remaining lease TTL.
Retain the minimum verified finite v2 limit across unreadable levels and report the first read error. A finite upper bound can establish or sustain pressure. A recovery decision still needs fresh RSS and sufficient ancestry coverage.
An eviction deadline stops new FIFO batch admission. A live cache completes one allocator purge for FIFO removals or idle-buffer releases already committed. Retirement keeps cleanup with Close.
Validation
03f5d055321e. Five affected packages passed full race UT on 57 with Go 1.27.1, and four regressions passed 100 race repetitions each. Formatting, err-check, vet, golangci-lint and molint passed across the seven-package incremental SCA scope. The previously failing CI testTestIssue29492MultiCNCancellationCleanuppassed on the final SHA under race, including text and binary protocol subtests.