Repository navigation
refactor(fileservice): consolidate memory cache allocation ownership - #28182
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? |
|
Unrelated CI blocker: Tracking issue: #28206. The failed jobs were rerun once from workflow attempt 1. |
a1b6dcb to
440ee7c
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed at a74b89d.
Design decision: the existing MemCache reservation API is the single physical-capacity owner. The factory now constructs that owner first and gives the same allocator directly to DiskCache and RemoteCache. With memory cache disabled, both retain their default allocator fallback; remote configuration is still rejected before any cache resource is created. Direct DiskCache and RemoteCache constructors preserve their standalone defaults. This consolidates an existing contract rather than changing the configured capacity, eviction policy, data format, or public API.
Unhappy-path audit:
- Q1 passes: Disk and validated Remote reads transfer one pending reservation with the returned Bytes; successful FIFO insertion commits it, while validation failure, duplicate or rejected admission, vector release, idle drain, Flush, and Close release it through the existing exact-once paths.
- Q2 passes: no wait or lock edge is added. Removing the legacy guard eliminates a redundant eviction path; reserveCacheData retains its non-blocking transient-buffer fallback when capacity cannot be obtained.
- Q3 passes: FIFO used bytes plus pending reservations remain under the hard MemCache capacity, and retained idle buffers remain bounded by size class, per-class count, explicit drains, and the same quota.
All removed tests covered the deleted wrapper itself; replacement tests exercise real LocalFS, S3FS, DiskCache, and RemoteCache allocation paths, owner identity, full-capacity eviction, reservation release, and disabled-cache fallback. Exact-head UT, SCA, and multi-CN BVT CI is green. The steady-state path removes interface checks and one FileService delegation, so there is no performance regression or log amplification. No blocker found.
Merge Queue Status
This pull request spent 14 minutes 46 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28182 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.
Failing checks:
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. Tick the box to put this pull request back in the merge queue (same as
|
…atrixorigin#28182) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#27138 ## What this PR does / why we need it: ### Root cause Memory Cache now reserves physical backing capacity before it allocates cache data. The standard FileService factory nevertheless retained a second capacity owner: DiskCache received the Memory Cache allocator and a separate FIFO cache pointer which wrapped allocations in `cacheCapacityGuardedAllocator` / `EnsureNBytes`. RemoteCache was also given a FileService wrapper instead of the Memory Cache allocator directly. These parallel mechanisms obscured the reservation owner and made future double reservation or bypass regressions likely. ### Changes - Make the factory construct Memory Cache before Remote Cache (after preserving the invalid-remote-config validation), and wire DiskCache and RemoteCache directly to the same `*MemCache` allocator. - Remove DiskCache’s legacy FIFO capacity pointer, guarded allocator, capacity-guard marker, and `ensureCacheDataCapacity`. - Keep LocalFS and S3FS allocator delegation intact; their cache-owned `Allocate`, `AllocateWithHint`, and `Copy` paths continue to enter Memory Cache reservation. - Keep ObjectIO column constructors on the FileService-injected allocator. Its independent Default allocator use is only for generated data that is not admitted to that FileService Memory Cache. ### Issue-to-test proof - `TestFileServiceCacheDataAllocatorsReserveBackingCapacity` covers LocalFS and S3FS `Allocate`, `AllocateWithHint`, and `Copy` at full capacity. - `TestDiskCacheReadUsesMemoryCacheReservation` fills the Memory Cache, reads through DiskCache, verifies allocator identity, eviction before allocation, backing-size reservation, owner identity, and release on vector/flush. - `TestRemoteCacheReadUsesMemoryCacheReservation` performs a validated remote hit against a full Memory Cache and verifies the same ownership, eviction, reservation, and release behavior. - `TestFileServiceCachesUseMemoryCacheAllocator` verifies the standard factory gives DiskCache and RemoteCache the one Memory Cache allocator. - Existing reservation lifecycle tests cover rehome-before-copy, FIFO usage commit, and duplicate insertion until data release. ObjectIO cache/vector tests verify validation and cache-admission forwarding, including remote column cache admission. ### Tests - `make -j8 cgo` - Focused FileService reservation tests - `mo-cgo-test -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=100 -run "^TestRemoteCacheReadUsesMemoryCacheReservation$" ./pkg/fileservice` - `mo-cgo-test -run "Test.*(Cache|Vector)" ./pkg/objectio` `TestMinioSDK/file_service/basic` was excluded only after reproducing the same `Access Denied` response against the local MinIO endpoint from an `origin/main` worktree. ### Residual risks This refactor does not change backing-size accounting, eviction policy, remote routing, or cache data layout. The changed boundary is exercised with race tests; external MinIO authorization remains an environment dependency. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#28182) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#27138 ## What this PR does / why we need it: ### Root cause Memory Cache now reserves physical backing capacity before it allocates cache data. The standard FileService factory nevertheless retained a second capacity owner: DiskCache received the Memory Cache allocator and a separate FIFO cache pointer which wrapped allocations in `cacheCapacityGuardedAllocator` / `EnsureNBytes`. RemoteCache was also given a FileService wrapper instead of the Memory Cache allocator directly. These parallel mechanisms obscured the reservation owner and made future double reservation or bypass regressions likely. ### Changes - Make the factory construct Memory Cache before Remote Cache (after preserving the invalid-remote-config validation), and wire DiskCache and RemoteCache directly to the same `*MemCache` allocator. - Remove DiskCache’s legacy FIFO capacity pointer, guarded allocator, capacity-guard marker, and `ensureCacheDataCapacity`. - Keep LocalFS and S3FS allocator delegation intact; their cache-owned `Allocate`, `AllocateWithHint`, and `Copy` paths continue to enter Memory Cache reservation. - Keep ObjectIO column constructors on the FileService-injected allocator. Its independent Default allocator use is only for generated data that is not admitted to that FileService Memory Cache. ### Issue-to-test proof - `TestFileServiceCacheDataAllocatorsReserveBackingCapacity` covers LocalFS and S3FS `Allocate`, `AllocateWithHint`, and `Copy` at full capacity. - `TestDiskCacheReadUsesMemoryCacheReservation` fills the Memory Cache, reads through DiskCache, verifies allocator identity, eviction before allocation, backing-size reservation, owner identity, and release on vector/flush. - `TestRemoteCacheReadUsesMemoryCacheReservation` performs a validated remote hit against a full Memory Cache and verifies the same ownership, eviction, reservation, and release behavior. - `TestFileServiceCachesUseMemoryCacheAllocator` verifies the standard factory gives DiskCache and RemoteCache the one Memory Cache allocator. - Existing reservation lifecycle tests cover rehome-before-copy, FIFO usage commit, and duplicate insertion until data release. ObjectIO cache/vector tests verify validation and cache-admission forwarding, including remote column cache admission. ### Tests - `make -j8 cgo` - Focused FileService reservation tests - `mo-cgo-test -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=100 -run "^TestRemoteCacheReadUsesMemoryCacheReservation$" ./pkg/fileservice` - `mo-cgo-test -run "Test.*(Cache|Vector)" ./pkg/objectio` `TestMinioSDK/file_service/basic` was excluded only after reproducing the same `Access Denied` response against the local MinIO endpoint from an `origin/main` worktree. ### Residual risks This refactor does not change backing-size accounting, eviction policy, remote routing, or cache data layout. The changed boundary is exercised with race tests; external MinIO authorization remains an environment dependency. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#28182) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#27138 ## What this PR does / why we need it: ### Root cause Memory Cache now reserves physical backing capacity before it allocates cache data. The standard FileService factory nevertheless retained a second capacity owner: DiskCache received the Memory Cache allocator and a separate FIFO cache pointer which wrapped allocations in `cacheCapacityGuardedAllocator` / `EnsureNBytes`. RemoteCache was also given a FileService wrapper instead of the Memory Cache allocator directly. These parallel mechanisms obscured the reservation owner and made future double reservation or bypass regressions likely. ### Changes - Make the factory construct Memory Cache before Remote Cache (after preserving the invalid-remote-config validation), and wire DiskCache and RemoteCache directly to the same `*MemCache` allocator. - Remove DiskCache’s legacy FIFO capacity pointer, guarded allocator, capacity-guard marker, and `ensureCacheDataCapacity`. - Keep LocalFS and S3FS allocator delegation intact; their cache-owned `Allocate`, `AllocateWithHint`, and `Copy` paths continue to enter Memory Cache reservation. - Keep ObjectIO column constructors on the FileService-injected allocator. Its independent Default allocator use is only for generated data that is not admitted to that FileService Memory Cache. ### Issue-to-test proof - `TestFileServiceCacheDataAllocatorsReserveBackingCapacity` covers LocalFS and S3FS `Allocate`, `AllocateWithHint`, and `Copy` at full capacity. - `TestDiskCacheReadUsesMemoryCacheReservation` fills the Memory Cache, reads through DiskCache, verifies allocator identity, eviction before allocation, backing-size reservation, owner identity, and release on vector/flush. - `TestRemoteCacheReadUsesMemoryCacheReservation` performs a validated remote hit against a full Memory Cache and verifies the same ownership, eviction, reservation, and release behavior. - `TestFileServiceCachesUseMemoryCacheAllocator` verifies the standard factory gives DiskCache and RemoteCache the one Memory Cache allocator. - Existing reservation lifecycle tests cover rehome-before-copy, FIFO usage commit, and duplicate insertion until data release. ObjectIO cache/vector tests verify validation and cache-admission forwarding, including remote column cache admission. ### Tests - `make -j8 cgo` - Focused FileService reservation tests - `mo-cgo-test -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservice` - `mo-cgo-test -race -count=100 -run "^TestRemoteCacheReadUsesMemoryCacheReservation$" ./pkg/fileservice` - `mo-cgo-test -run "Test.*(Cache|Vector)" ./pkg/objectio` `TestMinioSDK/file_service/basic` was excluded only after reproducing the same `Access Denied` response against the local MinIO endpoint from an `origin/main` worktree. ### Residual risks This refactor does not change backing-size accounting, eviction policy, remote routing, or cache data layout. The changed boundary is exercised with race tests; external MinIO authorization remains an environment dependency. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Related to #27138
What this PR does / why we need it:
Root cause
Memory Cache now reserves physical backing capacity before it allocates cache data. The standard FileService factory nevertheless retained a second capacity owner: DiskCache received the Memory Cache allocator and a separate FIFO cache pointer which wrapped allocations in
cacheCapacityGuardedAllocator/EnsureNBytes. RemoteCache was also given a FileService wrapper instead of the Memory Cache allocator directly. These parallel mechanisms obscured the reservation owner and made future double reservation or bypass regressions likely.Changes
*MemCacheallocator.ensureCacheDataCapacity.Allocate,AllocateWithHint, andCopypaths continue to enter Memory Cache reservation.Issue-to-test proof
TestFileServiceCacheDataAllocatorsReserveBackingCapacitycovers LocalFS and S3FSAllocate,AllocateWithHint, andCopyat full capacity.TestDiskCacheReadUsesMemoryCacheReservationfills the Memory Cache, reads through DiskCache, verifies allocator identity, eviction before allocation, backing-size reservation, owner identity, and release on vector/flush.TestRemoteCacheReadUsesMemoryCacheReservationperforms a validated remote hit against a full Memory Cache and verifies the same ownership, eviction, reservation, and release behavior.TestFileServiceCachesUseMemoryCacheAllocatorverifies the standard factory gives DiskCache and RemoteCache the one Memory Cache allocator.Tests
make -j8 cgomo-cgo-test -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservicemo-cgo-test -race -count=1 -timeout=600s -skip "^TestMinioSDK$" ./pkg/fileservicemo-cgo-test -race -count=100 -run "^TestRemoteCacheReadUsesMemoryCacheReservation$" ./pkg/fileservicemo-cgo-test -run "Test.*(Cache|Vector)" ./pkg/objectioTestMinioSDK/file_service/basicwas excluded only after reproducing the sameAccess Deniedresponse against the local MinIO endpoint from anorigin/mainworktree.Residual risks
This refactor does not change backing-size accounting, eviction policy, remote routing, or cache data layout. The changed boundary is exercised with race tests; external MinIO authorization remains an environment dependency.