Skip to content

fix: restore minimal RSS cache pressure protection - #24612

Merged
XuPeng-SH merged 7 commits into
matrixorigin:4.0-devfrom
LeftHandCold:revert-diskcache-eviction
May 26, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:4.0-devfrom
LeftHandCold:revert-diskcache-eviction

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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:

  1. Revert the prior cache/PK-path changes from fix: reduce CN RSS pressure under TPCC #24535, fix: cap fileservice event logger during cache eviction #24542, and fix: keep cache pressure target under high RSS #24543 as a clean baseline.
  2. Keep the low-risk fileservice event logger cap and strip request event logging from cache-capacity eviction before cache-data allocation.
  3. Under RSS pressure, asynchronously evict fileservice memory cache and objectio metadata cache to a bounded target.
  4. Run CN memory-cache and metadata-cache pressure eviction concurrently so one slow cache family cannot consume the shared pressure timeout and skip the other.
  5. Keep a short pressure admission target so memory/meta cache writes do not immediately refill the just-evicted caches.
  6. Do not change PK check concurrency behavior beyond reverting the risky metadata/BF/tombstone scope expansion.
  7. Do not change tombstone, metadata, or bloom-filter read policy.
  8. Keep foreground cache allocation from consuming global async eviction debt.
  9. Add pressure logs and metrics for RSS trigger, cache eviction duration, and admission skips.

The intended behavior is:

  • Normal RSS: no cache throttling or PK-path behavior change.
  • High RSS: background cache/meta eviction plus temporary cache-admission suppression.
  • Foreground reads/writes: no global PK semaphore expansion, no tombstone policy change, no metadata/BF policy change.

Test

git diff --check
git diff --check base/4.0-dev...HEAD
GOCACHE=/private/tmp/mo-gocache go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/vm/engine/disttae -run 'TestTombstonePKExistsInRange|TestLinearSearchOffsetByValFactory' -count=1
GOCACHE=/private/tmp/mo-gocache go test ./pkg/vm/engine/disttae -run 'TestPKCheckSemaphore|TestTombstonePKExistsInRange' -count=1

Copilot AI review requested due to automatic review settings May 26, 2026 10:34
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pkCheckSemaphore usage in PKPersistedBetween to cover only the candidate block PK-column read loop (not object metadata/BF/tombstone checks).
  • Simplify/adjust cache/event-logging plumbing (including removal of withoutEventLogger and 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.

Comment thread pkg/vm/engine/disttae/txn_table.go Resolved
Comment thread pkg/objectio/ioutil/funcs.go Resolved
Comment thread pkg/fileservice/event_logger.go Resolved
Comment thread pkg/fileservice/event_logger.go Resolved
Comment thread pkg/fileservice/fifocache/fifo.go Resolved
Comment thread pkg/vm/engine/disttae/engine.go Resolved
@LeftHandCold
LeftHandCold requested a review from aptend as a code owner May 26, 2026 10:54
@LeftHandCold LeftHandCold changed the title Revert diskcache eviction fix: restore minimal RSS cache pressure protection May 26, 2026

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=false for 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 in tryScavengeRSS prevents 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.

@mergify

mergify Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-26 14:58 UTC · Rule: release-4.0
  • 🚫 Left the queue — 2026-05-26 15:22 UTC · at 224462df54931107e72db3ad571bf31c92787e4b

This pull request spent 24 minutes 34 seconds in the queue, with no time running CI.

Reason

Pull 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.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You 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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

@XuPeng-SH
XuPeng-SH merged commit e941462 into matrixorigin:4.0-dev May 26, 2026
47 of 55 checks passed
@mergify mergify Bot added dequeued and removed queued labels May 26, 2026
mergify Bot pushed a commit that referenced this pull request May 27, 2026
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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants