History

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.

Sebastian Thiel committed 4 years ago

Commit 1d995ef1 parent a79a7fb1 file · +3 −3Browse files

Unified · Split

git-odb/src/store_impls/dynamic/load_index.rs+3−3
@@ -157,7 +157,7 @@ impl super::Store { · 156 unmodified lines
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 { · 208 unmodified lines
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