Repository navigation
Description
What happened
In pkg/yurthub/storage/disk/storage.go, ReplaceComponentList() is responsible for atomically replacing the full set of cached objects for a given component/resource during a cloud-reconnect resync. It acquires a pending lock on the key prefix (via lockComponentKey()), writes all objects from the fresh LIST response to a staging area, then promotes them to the final cache directory.
During the resync window while ReplaceComponentList() holds the pending lock, any concurrent Update() or Create() calls for objects under the same key prefix (coming from concurrent watch events that arrived during the same reconnect window) hit lockKey(), detect the pending lock, and return storage.ErrStorageAccessConflict.
In pkg/yurthub/cachemanager/cache_manager.go, storeObjectWithKey() catches ErrStorageAccessConflict and — even after the fix in PR #2712 — only avoids updating the in-memory cache, but does NOT retry the disk write after the lock is released. Once ReplaceComponentList() completes and promotes its snapshot, those conflicting objects are permanently absent from disk with no mechanism to re-request or re-write them.
The consequence is that the final disk cache after a resync may be missing objects that arrived via watch between the LIST response and the completion of ReplaceComponentList(). On the next edge-autonomous period (cloud disconnect), YurtHub serves this incomplete snapshot to Kubelet.
What you expected to happen
Objects that arrive via watch during a ReplaceComponentList() resync window should either be included in the replacement snapshot, or be reliably retried for disk write after the lock is released. The disk cache should reflect a consistent state that includes both the LIST snapshot and any watch events received during the resync.
How to reproduce it (as minimally and precisely as possible)
- Run
go test -race -v ./pkg/yurthub/cachemanager/... - Set up a test where
ReplaceComponentList()is artificially delayed (via a channel/sync mechanism in a fake storage wrapper) while a concurrentCacheResponse()watch event for a new object under the same prefix is injected. - After both complete, read the object from disk cache and confirm it is absent — only the LIST snapshot objects are present.
Anything else we need to know?
- Severity: High. This is a data-loss bug affecting edge autonomy correctness — the exact scenario OpenYurt is designed to protect. A disconnected edge node will serve Kubelet an incomplete/stale snapshot that silently omits objects that were legitimately created/updated just before the disconnect. The missing state is permanent on disk until the next full resync (i.e. next cloud reconnect + LIST), and does not self-heal between reconnects.
- Context: This is structurally related to PR [BUG] Silent watch event drop during disk storage list-replacement causes permanent cache inconsistency between memory and disk #2712 (watch event drop during
ReplaceComponentList) but affects a different code path — that fix prevented in-memory divergence; this gap means disk itself is also missing the object.
Environment
- OpenYurt version:
masterbranch - Kubernetes version: N/A (code-level defect)
- OS: N/A
- Kernel: N/A
- Install tools: N/A
/kind bug
Activity
WorrierKhushal commentedon Aug 28, 2026
Hi maintainers, I've traced this issue and have a concrete fix plan ready.
Root Cause
ReplaceComponentList()holds a pending lock (lockComponentKey()) across its full disk I/O sequence. Concurrent watch events arriving during this window hitErrStorageAccessConflictinUpdate()/Create()and are permanently dropped from disk — the #2712 fix correctly prevented in-memory divergence, but the disk write was never retried, leaving the on-disk snapshot silently incomplete after every resync.Proposed Approach
After
ReplaceComponentList()completes and releases its lock, any watch events that were rejected withErrStorageAccessConflictduring the locked window need to be durably written to disk.When
storeObjectWithKey()catchesErrStorageAccessConflict, instead of returning silently, it enqueues the key + object into a small pending buffer owned byCacheManager. A goroutine (or the existingsaveWatchObjectretry path) drains this buffer after the lock releases, reusing the existingsaveOneObject()write path so no new disk I/O pattern is introduced.Why this is the cleanest approach:
saveOneObject()— the existing, already-tested single-object write path used throughoutcache_manager.go.storage.Store.Code Draft (
pkg/yurthub/cachemanager/cache_manager.go)go
###Call Site Audit
storeObjectWithKey() is called from saveWatchObject() and saveOneObject() only (grep -rn "storeObjectWithKey" pkg/).
ReplaceComponentList() is called from saveListObject() only (grep -rn "ReplaceComponentList" pkg/).
No public interface changes made; no other callers affected.
###Testing Plan
Add a deterministic test in cache_manager_test.go using a channel-controlled fake StorageWrapper (following the pattern of TestWatchDuringReplaceComponentListKeepsMemoryAndDiskConsistent added in #2712) to:
Force a concurrent watch event during ReplaceComponentList()'s locked window.
After both goroutines complete, read the object directly from the disk cache (not just in-memory cache) and assert its presence.
This test will fail on master and pass with this fix.
###Verification Workflow
go build ./pkg/yurthub/cachemanager/...
go build ./pkg/yurthub/storage/disk/...
go vet ./pkg/yurthub/cachemanager/...
go test -v ./pkg/yurthub/cachemanager/...
go test -race -v ./pkg/yurthub/cachemanager/...
No exported signatures changed. No new interfaces introduced. Minimal, scoped change reusing existing write infrastructure.
Would appreciate your feedback before opening the PR — happy to adjust if you see a simpler path!
WorrierKhushal commentedon Aug 29, 2026
Hi @zyjhtangtang @luc99hen @Fei-Guo maintainers,
i am just opened the PR #2786 for the issues Silent object loss during disk cache ReplaceComponentList when concurrent writes arrive mid-resync in YurtHub
if you have the time please review my this PR
stale commentedon Dec 4, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.