Fully materialize an ObjectLoader before returning it from ObjectDatabase
commitfe6c8248e1ed6bd9db76a8314103081a02d55393
authorShawn O. Pearce <spearce@spearce.org>
Thu, 23 Apr 2009 03:36:21 +0000 (22 20:36 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 23 Apr 2009 22:25:58 +0000 (24 00:25 +0200)
tree21f6be8fc52d6300f6c6d31c9ba5bd985097c4ad
parent5a7cb59846128a9b2926f39d277c630673ce2a5d
Fully materialize an ObjectLoader before returning it from ObjectDatabase

By forcing the ObjectLoader to fully reconstruct the requested object
and store it under getCachedBytes() before we return the ObjectLoader
to the caller we can ensure that the underlying PackFile remains valid
throughout the entire load.

If memory pressure causes the PackFile's windows to be evicted, and
the pack closes, and is replaced underneath of us, we can correctly
catch and handle the PackMismatchException or IOException by closing
the pack, rescanning the ObjectDirectory, and starting our search all
over again.  Doing so is expensive, as we may have already unpacked
a large part of the object's delta chain before finding the pack was
modified, but its better than failing outright due to a race condition.

Note that this does not resolve the concurrent access problems in
PackWriter, as the cached PackedObjectLoaders are referenced very
late, and go back to the original PackFile, not the cached store.

Because we fully access the pack data up front during materialize()
we no longer need to hold the WindowCursor inside of the individual
loader instance.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/lib/DeltaOfsPackedObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/DeltaPackedObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackedObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/WholePackedObjectLoader.java