]> source.dussan.org Git - jgit.git/commit
Insert duplicate objects to prevent race during garbage collection. 82/59282/3
authorMike Williams <miwilliams@google.com>
Wed, 21 Oct 2015 20:09:58 +0000 (16:09 -0400)
committerShawn Pearce <spearce@spearce.org>
Thu, 5 Nov 2015 06:25:07 +0000 (22:25 -0800)
commitc4d73fb7cc2bd4a853d9657bb074719546294ae1
tree51bba42ef669f10d0e9276a5e27e269cdfa1f48f
parent63e15c7533194463c2d2e4dcaf552e01bd117ee9
Insert duplicate objects to prevent race during garbage collection.

Prior to this change, DfsInserter would not insert an object into a pack
if it already existed in another pack in the repository, even if that
pack was unreachable. Consider this sequence of events:

- Object FOO is pushed to a repository.
- Subsequent ref changes make FOO UNREACHABLE_GARBAGE.
- FOO is subsequently re-inserted using a DfsInserter, but skipped
  due to existing in UNREACHABLE_GARBAGE.
- The repository is repacked; FOO will not be written into a new pack
  because it is not yet reachable from a reference. If the
  UNREACHABLE_GARBAGE packs are deleted, FOO disappears.
- A reference is updated to reference FOO. This reference is now broken
  as FOO was removed when the repacking process deleted the
  UNREACHABLE_GARBAGE pack that stored the only copy of FOO.

The garbage collector can't safely delete the UNREACHABLE_GARBAGE
pack because FOO might be in the middle of being re-inserted/re-packed.

This change writes a duplicate copy of an object if it only exists in
UNREACHABLE_GARBAGE. This "freshens" the object to give it a chance to
survive long enough to be made reachable through a reference.

Change-Id: I20f2062230f3af3bccd6f21d3b7342f1152a5532
Signed-off-by: Mike Williams <miwilliams@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java