fix: retry disk writes dropped during ReplaceComponentList resync window to prevent silent object loss in edge cache - #2786
Open
WorrierKhushal wants to merge 2 commits into
Conversation
…ade responses - Replace pooled bufio reader with unpooled bufio.NewReader in getResponse to prevent premature recycling before serveUpgradeRequest writes the response body. - Add TestServeUpgradeRequest_ConcurrentRace to validate thread safety under concurrent requests.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2786 +/- ##
==========================================
+ Coverage 46.20% 46.29% +0.09%
==========================================
Files 405 405
Lines 27540 27583 +43
==========================================
+ Hits 12724 12769 +45
+ Misses 13649 13636 -13
- Partials 1167 1178 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What type of PR is this?
/kind bug
What this PR does / why we need it:
During a cloud-reconnect resync,
ReplaceComponentList()inpkg/yurthub/storage/disk/storage.goholds a pending lock(
lockComponentKey()) across its full disk I/O sequence. Any concurrentwatch events arriving for objects under the same key prefix during this
window hit
ErrStorageAccessConflictinUpdate()/Create()and arepermanently dropped from disk.
PR #2712 correctly fixed the in-memory divergence half of this problem —
it prevented the in-memory cache from getting ahead of disk when a
conflict occurs. But the disk write itself was still never retried, so
the on-disk snapshot after every resync silently omits any objects that
arrived via watch during the replace window.
On the next edge-autonomous period (cloud disconnect), YurtHub serves
this incomplete snapshot to Kubelet — missing objects that were
legitimately created or updated just before the disconnect. The missing
state is permanent on disk until the next full resync.
This PR fixes the second half: when
storeObjectWithKey()catchesErrStorageAccessConflict, it now enqueues the key+object into a smallpendingWritesbuffer onCacheManager. AfterReplaceComponentList()completes and releases its lock,
saveListObject()drains this bufferusing the existing
saveOneObject()write path — reusing already-testedinfrastructure, no new disk I/O patterns, no
storage.Storeinterfacechanges.
Added a deterministic regression test that forces the exact conflict
window using a channel-controlled fake
StorageWrapper(same patternas the test added for #2712), confirms the object is absent from disk
before the fix, and present after.
Which issue(s) this PR fixes:
Fixes #2780
Special notes for your reviewer:
go test -race -v ./pkg/yurthub/cachemanager/...— zero races, alltests pass including the new regression test
go buildandgo veton bothcachemanagerandstorage/disk—clean
storage.Storeinterface unchanged — no downstream implementersaffected
saveOneObject()unchanged — reused as the drain write path onlydivergence; this PR fixes the disk-only silent object loss
Does this PR introduce a user-facing change?
other Note