Repository navigation
fix(cache): preserve full object identity in shared chunk cache - #5225
singh4jitendra wants to merge 6 commits into
Conversation
Keep wrapped bucket requests mount-relative while shared cache paths use full object names. Version cache keys to isolate legacy entries and cover prefix isolation, overlapping views, and legacy cache reuse with regressions.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the shared chunk cache manager to use versioned keys (v2) to prevent the reuse of older mount-relative entries, updating the hashing logic and corresponding unit tests. It also introduces prefix-aware caching by passing the onlyDir configuration parameter to the SharedChunkCacheReader and constructing the cache object name with this prefix. Regarding the review feedback, it is recommended to clean and normalize configuration parameters like onlyDir during the initial configuration validation phase rather than repeatedly in downstream utility functions.
Clarify the shared-reader normalized only-dir precondition. Exercise cfg.Rationalize in the cache-reuse regression, including redundant slashes, dot and parent segments, root paths, and literal object-name separators. Keep normalization centralized rather than cleaning object names in downstream readers.
d0a6b8e to
0837c9b
Compare
|
Hi @abhishek10004 , PR is Ready for review, please have a look. |
|
Could you also add an e2e test in For background on how our e2e suites are structured and configured, we have a step-by-step runbook in the repo at Specifically for
Once you push, we'll trigger the e2e presubmit on the PR. |
Remount the secondary shared-cache instance with the test prefix using config-based helpers. Verify matching range data, one cached chunk and unchanged file modification times, and fail cache snapshots on filesystem errors. Keep the existing bucket compatibility and managed-mount teardown.
|
@PranjalC100 Added
Local validation with Go 1.27.2:
No authorized cloud test bucket is configured locally, so the real E2E execution has not been run. Please trigger the E2E presubmit as offered. For a manual run on a configured test VM, substitute an authorized compatible bucket: BUCKET_NAME=<compatible-test-bucket> GODEBUG=asyncpreemptoff=1 go test -p 1 ./tools/integration_tests/shared_chunk_cache -run 'TestSharedChunkCacheTestSuite/TestCacheHitWithOnlyDir' --integrationTest -v --config-file="$(pwd)/tools/integration_tests/test_config.yaml"Warning Cloudtop/Jetski sessions can fail or hang on full integration tests because of proxy, FUSE, or credential-scope restrictions. If that occurs, use the designated GCP Linux test VM/sandbox or the presubmit environment instead. |
|
Hi @abhishek10004 @anushka567 @meet2mky, could one of you take a look when you get a chance? I've added the cross-mount |
|
Please resolve the existing comments on the PR. |
|
Hi @PranjalC100, following up on your note: all the inline comments are resolved, and the cross-mount |
| fmt.Fprintf(h, "%d:%s", len(bucketName), bucketName) | ||
| fmt.Fprintf(h, "%d:%s", len(objectName), objectName) | ||
| fmt.Fprintf(h, ":%d", generation) | ||
| // Version keys to avoid reusing entries written with mount-relative object names. |
There was a problem hiding this comment.
Can we keep the existing hash format without the v2: prefix?
The cache key already includes generation (<bucketLen>:<bucket><objLen>:<objectName>:<generation>). Once --only-dir mounts pass the full object name, they will look up <onlyDir>/<file> and naturally ignore any legacy entry written under <file>. A legacy entry written under --only-dir could only be mistakenly read by a root mount if a different object existed at the bucket root with the exact same name and the exact same 64-bit microsecond GCS generation number. @vadlakondaswetha What do you think?
--
Minor (allocation): fmt.Sprintf + []byte(key) allocates both a string and a []byte. Using fmt.Appendf avoids the extra copy:
hash := sha256.Sum256(fmt.Appendf(nil, "%d:%s%d:%s:%d", len(bucketName), bucketName, len(objectName), objectName, generation))There was a problem hiding this comment.
I've removed v2: and used fmt.Appendf as suggested in 8612f4d. The original hash fixtures are restored. A new compatibility test pre-populates an old-format root entry and removes the fake backend object, so it proves the entry is reused rather than downloaded again. The prefixed-view test also checks that a mount-relative entry is skipped.
That keeps this focused on using the correct object name, without invalidating every existing root cache. It retains the pre-existing legacy-cache edge case you noted; I'm not claiming that old ambiguous entries are independently validated. I'll leave this thread open for @vadlakondaswetha's input since you asked for it. Happy to adjust if you'd prefer a different migration policy.
Merge current master without rewriting PR history. Preserve the PR behavior while adopting the upstream v4 module path, Go 1.27.4 and dependency security updates. Validated with relevant race tests and make build.
|
Merged the latest master in 1728439 and resolved the v4 import conflict. The cache identity fix and cross-mount E2E test are unchanged. Rechecked with Go 1.27.4:
The branch is updated without rewriting history. The cloud-backed E2E presubmit will need to run on the new commit. |
Use bucket.GCSName as the source of the full object name and restore the original reader signature. Preserve the existing hash format with fmt.Appendf and cover compatible root-cache reuse and prefixed cache isolation.
|
Hi @PranjalC100 @abhishek10004, I've pushed the updates from the last review. Could you take another look when you get a chance? A hand approving the latest CI run would be great too. Thanks! |
|
Hi @PranjalC100 @abhishek10004, could you wrap up the review when you get a chance and merge once the checks pass and everything looks good? Thanks! |
|
Hi @PranjalC100 @vadlakondaswetha, just following up on this one. The review changes and cross-mount test are in. Could you help confirm the remaining hash-policy decision and get the latest CI runs approved when you have a chance? Thanks! |
|
Hi @PranjalC100 @vadlakondaswetha, could you help with the remaining hash-policy decision and CI approval when you have a moment? Please let me know if anything else is needed from my side. Thanks! |
Match include/exclude rules against the bucket name and full GCS object name, including only-dir prefixes. Add prefixed-bucket read regressions for full and mount-relative patterns and exclusion precedence. Rename existing-format cache fixture variables for clarity.
|
Hi @abhishek10004, both review fixes are in. Could you take another look when you have a moment? Thanks! |
Description
The shared chunk cache was using mount-relative object names, so different views of the same bucket could miss or mix cache entries.
bucket.GCSName(object)for cache identity. The bucket supplies the full name, so the reader needs no extraonlyDirargument or duplicated configuration.fmt.Appendf. Existing root-mount cache entries remain reusable.--only-dirmount.The equal-generation cases use fake buckets to exercise the identity boundary. This is a cache-correctness fix, not a claim that an attacker can choose a GCS generation.
Link to the issue in case of a bug fix.
Fixes #5224
Testing details
Latest validation used Go 1.27.4 and the v4 module on Ubuntu 24.04 under WSL.
make build- passed, including generation, formatting, vet, lint (0 issues), and compilation.go test -mod=readonly -p 1 -count=1 -timeout=90s -run 'TestSharedChunkCacheSeparatesOnlyDirPrefixes|TestSharedChunkCacheReaderTestSuite/TestReadAt_ReusesExistingRootCacheEntries' ./internal/gcsx ./internal/gcsx/read_manager- failed as expected, demonstrating dependence on duplicated config and the unnecessary root-cache invalidation.go test -mod=readonly -p 1 -count=1 -race -timeout=5m ./internal/gcsx ./internal/gcsx/read_manager ./internal/cache/file- passed after the update.go test -mod=readonly -c -o "$binary" ./tools/integration_tests/shared_chunk_cache- passed (compilation only; the task-owned binary was removed).TestCacheHitWithOnlyDirchecks matching bytes, one cached chunk, and unchanged cache-file modification time across the two mounts.Any backward incompatible change? If so, please explain.
No CLI, reader-constructor, or hash-format change. Correct root-mount entries remain usable. Prefixed views now use the full GCS name and naturally skip older mount-relative entries; this does not add a blanket invalidation or verification of old cache contents.