fix: image cache sync issue #18

Merged
salmaelsoly merged 3 commits from master_store_sync into development 2026-03-04 09:34:19 +00:00
Member

#12

#12
feat: intial file locking and atomic writes
Some checks failed
Unit and Integration Test / test (push) Failing after 13s
08e2d10ce4
refactor: streamline index loading and error handling in ImageCache and FileLock
All checks were successful
Unit and Integration Test / test (push) Successful in 2m16s
91f2886f67
salmaelsoly changed title from WIP: fix: image cache sync issue to fix: image cache sync issue 2026-02-23 11:28:53 +00:00
salmaelsoly changed target branch from main to development 2026-02-26 08:03:31 +00:00
salmaelsoly changed title from fix: image cache sync issue to WIP: fix: image cache sync issue 2026-02-26 12:41:57 +00:00
salmaelsoly changed title from WIP: fix: image cache sync issue to fix: image cache sync issue 2026-03-02 08:34:40 +00:00
rawan requested changes 2026-03-03 11:03:52 +00:00
Dismissed
@ -92,6 +117,8 @@ impl ImageCache {
}
pub fn get(&self, reference: &str) -> Result<CachedImage> {
let _lock = FileLock::shared(&self.index_path())?;
Member

why are we file locking here?
when the function just reads from the in-memory self.index?

or should we reload_index here after locking to get the latest version?

why are we file locking here? when the function just reads from the in-memory self.index? or should we `reload_index` here after locking to get the latest version?
salmaelsoly marked this conversation as resolved
@ -5,0 +56,4 @@
}
/// Get the path of the lock file.
pub fn path(&self) -> &Path {
Member

this is never used, we can remove it or #[allow(dead_code)] if it will be needed later

this is never used, we can remove it or `#[allow(dead_code)]` if it will be needed later
salmaelsoly marked this conversation as resolved
@ -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)?;
Member

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.

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.
salmaelsoly marked this conversation as resolved
refactor: optimize state loading in StateStore and remove unnecessary locks
All checks were successful
Unit and Integration Test / test (push) Successful in 1m44s
015fc7881a
rawan approved these changes 2026-03-03 14:18:56 +00:00
salmaelsoly merged commit ea2b1f1b64 into development 2026-03-04 09:34:19 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_code/my_hypervisor!18
No description provided.