From c6831974b8f0f8cb6c1388905c2995c19f07351a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 14 Sep 2025 22:20:31 +0000 Subject: [PATCH] Fix: Skip expired lease entries with future expiry times Co-authored-by: miles.frankel --- src/storage.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/storage.rs b/src/storage.rs index 22a53cb..bf50851 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -603,6 +603,17 @@ impl Storage { message::ReaderOptions::new(), )?; let lease_entry_reader = lease_msg.get_root::()?; + + // If the lease entry itself indicates an expiry in the future, this + // expiry index key is stale (e.g., the lease was extended). In that + // case, clean up the stale index key and skip expiring this lease. + let lease_expiry_ts_secs = lease_entry_reader.get_expiry_ts_secs(); + if lease_expiry_ts_secs > now_secs { + // Delete the stale index entry and continue. Do not count as processed. + expiry_index_keys_to_delete.push(idx_key.to_vec()); + continue; + } + let keys = lease_entry_reader.get_ids()?; // Reuse capnp builder and output buffer across items to reduce allocations.