Skip to content

Commit 1d995ef

Browse files
committed
Don't reset generations, instead make them match the current one (#287)
That way, even empty slots can be identified as 'changed' compared to some older index even if they are empty. This makes it consistent, as indices refer to occupied slots only and protect themselves from changes using the generation flag, which usually comes first.
1 parent a79a7fb commit 1d995ef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-odb/src/store_impls/dynamic/load_index.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl super::Store {
157157

158158
/// refresh and possibly clear out our existing data structures, causing all pack ids to be invalidated.
159159
/// `load_new_index` is an optimization to at least provide one newly loaded pack after refreshing the slot map.
160-
fn consolidate_with_disk_state(&self, load_new_index: bool) -> Result<Option<Snapshot>, Error> {
160+
pub(crate) fn consolidate_with_disk_state(&self, load_new_index: bool) -> Result<Option<Snapshot>, Error> {
161161
let index = self.index.load();
162162
let previous_index_state = Arc::as_ptr(&index) as usize;
163163

@@ -372,8 +372,8 @@ impl super::Store {
372372
};
373373
slot.files.store(files);
374374
if !needs_stable_indices {
375-
// Not racy due to lock, generation must be set after unsetting the value AND storing it.
376-
slot.generation.store(0, Ordering::SeqCst);
375+
// Not racy due to lock, generation must be set after unsetting the slot value AND storing it.
376+
slot.generation.store(generation, Ordering::SeqCst);
377377
}
378378
}
379379

0 commit comments

Comments
 (0)