fix: image cache sync issue #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master_store_sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#12
WIP: fix: image cache sync issueto fix: image cache sync issuefix: image cache sync issueto WIP: fix: image cache sync issueWIP: fix: image cache sync issueto fix: image cache sync issue@ -92,6 +117,8 @@ impl ImageCache {}pub fn get(&self, reference: &str) -> Result<CachedImage> {let _lock = FileLock::shared(&self.index_path())?;why are we file locking here?
when the function just reads from the in-memory self.index?
or should we
reload_indexhere after locking to get the latest version?@ -5,0 +56,4 @@}/// Get the path of the lock file.pub fn path(&self) -> &Path {this is never used, we can remove it or
#[allow(dead_code)]if it will be needed later@ -122,2 +141,4 @@pub fn update_status(&mut self, vm_id: &str, status: VmState) -> Result<()> {let state_path = self.state_path(vm_id);let _lock = FileLock::exclusive(&state_path)?;Now update_status acquires the lock, then calls reload_state → load_state, which acquire a shared (read) lock, it will block until the lock is acquired (it will never be acquired because the caller has it)
but update_status has no callers, but i think it will deadlock once called
Fix: Split into load_state (locks) and load_state_inner (no lock). Have reload_state call the inner version. Then methods that already hold a lock can safely reload.