Repository navigation
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Pn7Hao.
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change protecting chunk reads from concurrent cache unmapping.
No open issues 🎉
What changed in this PR
This PR protects orchestrator chunk reads from concurrent cache unmapping, allowing cache-closed errors to reach the existing retry logic instead of failing guest reads with memory faults.
Changes:
- Separates data readiness from mmap access and holds the cache read lock through copying.
- Preserves streamed-prefix reads and borrowed
Slicebehavior. - Adds regression tests for eviction after readiness, partial streaming reads, and empty reads at EOF.
| File | Description |
|---|---|
packages/orchestrator/pkg/sandbox/block/streaming_chunk.go |
Guards mmap access and copying against concurrent cache closure. |
packages/orchestrator/pkg/sandbox/block/streaming_chunk_close_test.go |
Tests eviction handling, streamed-prefix reads, and empty EOF reads. |
Review effort: Balanced
d1e419f to
398e645
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @Pn7Hao on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @Pn7Hao on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Concurrent diff-cache eviction can unmap a cache after
Chunker.Slicereturns but beforeChunker.ReadAtcopies the bytes. The NBD fault guard then reports aMemoryFaultError, bypassingFile.readAt's existingCacheClosedErrorretry and failing the guest read.Separate waiting for data from acquiring the mmap slice. Protect mmap-header access and keep the cache read lock through
ReadAt's copy. The lock is released before fetching, so a pending close cannot deadlock a fetch that needs its own read lock. A ready streaming prefix remains readable before the full chunk is marked cached; empty reads at EOF also retain their behavior.Slicestill returns borrowed storage whose lifetime belongs to its caller.The regression test closes the cache from the existing readiness metric callback, placing eviction deterministically between readiness and copying without adding a production test hook. On unmodified
df41cd32, it producesMemoryFaultError; with this change it returnsCacheClosedErrorand leaves the destination untouched. Two additional tests cover partial streaming reads and empty reads at EOF.Validation:
go test -race ./pkg/sandbox/block -run '^TestChunker_' -parallel 2 -count=1 -timeout 90spasses.df41cd32with the expected invalid-memory fault.golangci-lint run --new-from-rev=HEAD --timeout=3m ./pkg/sandbox/block/...passes before committing.