Repository navigation
fix: restore minimal RSS cache pressure protection - #24612
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? |
There was a problem hiding this comment.
Pull request overview
This PR reverts recent “cache pressure / eviction” functionality across FileService caches and RSS throttling, while also narrowing the PKPersistedBetween PK-check semaphore scope to avoid global throttling across metadata/BF/tombstone reads (as described in issue #24592).
Changes:
- Remove RSS-triggered cache eviction + cache “pressure admission” mechanisms (and associated tests), reverting caches toward simpler FIFO eviction behavior.
- Narrow
pkCheckSemaphoreusage inPKPersistedBetweento cover only the candidate block PK-column read loop (not object metadata/BF/tombstone checks). - Simplify/adjust cache/event-logging plumbing (including removal of
withoutEventLoggerand event logger drop limits).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/vm/engine/disttae/util_test.go | Removes tests related to SkipFullFilePreloads and semaphore fast-path behavior. |
| pkg/vm/engine/disttae/txn_table.go | Narrows PK-check semaphore scope; changes PK/tombstone read policy handling. |
| pkg/vm/engine/disttae/logtailreplay/partition_state.go | Updates ReadDeletes call sites after signature/policy changes. |
| pkg/vm/engine/disttae/local_disttae_datasource.go | Updates ReadDeletes call sites after signature/policy changes. |
| pkg/vm/engine/disttae/engine.go | Removes Workspace mem throttler RSS cache-eviction configuration and restructures throttler creation. |
| pkg/objectio/meta_test.go | Removes tests for meta-cache eviction/admission pressure behavior. |
| pkg/objectio/ioutil/loadfuncs_test.go | Removes tests that asserted FileService policy propagation into reads. |
| pkg/objectio/ioutil/funcs.go | Changes ReadDeletes signature (drops policy parameter) and hardcodes default policy usage. |
| pkg/objectio/cache.go | Removes meta-cache pressure admission + percent-based eviction helper. |
| pkg/fileservice/s3_fs.go | Stops stripping event logger from ctx for EnsureNBytes calls. |
| pkg/fileservice/mem_cache.go | Removes memory-cache pressure admission + eviction-to-target helpers. |
| pkg/fileservice/mem_cache_test.go | Removes tests for memory-cache pressure admission and percent eviction helpers. |
| pkg/fileservice/local_fs.go | Stops stripping event logger from ctx for EnsureNBytes calls. |
| pkg/fileservice/fscache/data_cache.go | Removes “evict-to-target/force-evict-with-wait” methods from interface. |
| pkg/fileservice/fifocache/fifo.go | Removes admission-target logic and “evict-to-target/force-evict-with-wait”; refactors EvictWithWait behavior. |
| pkg/fileservice/fifocache/fifo_test.go | Removes tests tied to admission-target and evict-to-target helpers. |
| pkg/fileservice/fifocache/data_cache.go | Removes admission-target plumbing; updates EnsureNBytes to new EvictWithWait signature. |
| pkg/fileservice/event_logger.go | Removes drop limits and withoutEventLogger; adjusts pooling and type assertions. |
| pkg/fileservice/event_logger_test.go | Removes tests for event drop limit and withoutEventLogger. |
| pkg/fileservice/disk_cache_test.go | Updates test cache implementation for interface changes. |
| pkg/fileservice/cache.go | Removes global “evict memory caches to capacity percent” helper. |
| pkg/fileservice/bytes.go | Stops stripping event logger from ctx for EnsureNBytes calls. |
| pkg/common/rscthrottler/resource_throttler.go | Removes RSS cache eviction option/logic; simplifies RSS scavenging behavior. |
| pkg/common/rscthrottler/resource_throttler_test.go | Removes tests for RSS-driven cache eviction behavior. |
| pkg/cnservice/server.go | Removes RSS cache evictor integration from CN memory throttler configuration. |
| pkg/cnservice/server_test.go | Removes tests validating the (now removed) RSS cache evictor behavior. |
aptend
left a comment
There was a problem hiding this comment.
Review: PR #24612 — restore minimal RSS cache pressure protection
Clean revert-and-restore approach. The key insight is that the prior cache/PK-path changes introduced too much risk, and this PR strips them back to only what is necessary.
What I like:
- PK semaphore scope change: Moving from per-block acquire/release to once-per-loop is actually more correct — releasing the semaphore between individual block reads defeated the concurrency-limiting purpose.
- Sequential eviction over concurrent goroutines: simpler, avoids timeout interdependency between the two cache families.
includeAsyncDebt=falsefor foreground eviction: ensures foreground cache allocation (EvictToTargetWithWait) is not consuming async eviction debt from the pressure path — clean separation.- Async eviction in throttler: the
go func()wrapping intryScavengeRSSprevents RSS scavenging from blocking the throttler loop. - Metrics: well-structured CounterVec + HistogramVec covering trigger, eviction, admission-skip, and duration — good observability for this path.
Edge cases handled: percent bounds clamping (0-100), admission skip in both mem_cache and dedupLoad, tombstone checking removed from semaphore scope.
Approved.
Merge Queue Status
This pull request spent 24 minutes 34 seconds in the queue, with no time running CI. ReasonPull request #24612 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. |
This PR ports the final minimal RSS cache pressure protection from #24612 to `main`. Background: - #24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - #24542 added fileservice event logger capacity protection. - #24543 kept cache pressure admission targets active under high RSS. - #24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky #24535/#24542/#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
What type of PR is this?
Which issue(s) this PR fixes:
issue #24592
What this PR does / why we need it:
This PR reverts the risky semantic changes from the previous RSS-pressure fixes, then restores only the minimal cache-pressure protection needed for high RSS:
The intended behavior is:
Test