| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adding an object-size-index command to the CLI with two actions:
* write: to write the object size index for the existing packs in a
repo without doing a full GC.
* check: to print the relevant config flags and state of the repo
Usage:
$ jgit object-size-index <action>
It will act on the local repository.
Change-Id: I39b932a498b729a8a7caeae8be366255d2b61e85
|
|
|
|
|
|
|
|
|
|
|
| |
To compare performance with/without object size index, is useful to
have a flag to control if the index is used.
We already have core.dfs.useObjectSizeIndex. We should deprecate that
and use this pack.useObjectSizeIndex, which works for both DFS and
non-DFS sides.
Change-Id: I2b18648bb2f86e0cf2f4a79e0296d948da9c7924
|
|\
| |
| |
| |
| |
| |
| |
| | |
* stable-7.3:
Shortcut PackWriter reuse selection when possible
Don't use Yoda style conditions to improve readability
Change-Id: Ic8ca92cfc294ca01540218151bafca889256847b
|
| |\
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* stable-7.2:
Shortcut PackWriter reuse selection when possible
Don't use Yoda style conditions to improve readability
Change-Id: I58a1b25260d883b92ea768dc36da0cf3db07e310
|
| | |\
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
* stable-7.1:
Shortcut PackWriter reuse selection when possible
Don't use Yoda style conditions to improve readability
Change-Id: I9cbf680cc043c52b13679098fb1ecbd9c1a9c97d
|
| | | |\
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.0:
Shortcut PackWriter reuse selection when possible
Don't use Yoda style conditions to improve readability
Change-Id: Ie86972c36c9d377a8c07171a047b452ef8ee190d
|
| | | | |\
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* stable-6.10:
Shortcut PackWriter reuse selection when possible
Don't use Yoda style conditions to improve readability
Change-Id: I37b2c28267353aec912d99f4014dcde92a3a04ef
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
The selection of object representations favors the delta representation
in the oldest pack file. In light of that, it favors the smallest whole
object representation. This was previously achieved by iterating over
all the available representations of an object by iterating over the
representations in each pack file from newest to oldest. This approach
can be very expensive when there are many packfiles in a repo. Since
this selection approach favors the oldest pack file, reverse the
iteration so that we can find the same representation much quicker and
then shortcut the search.
For more background information as to how the selection process is
intended to operate, see I9953ab8be54ceb8b588e1280d6f7edd688887747. This
change hopes to additionally document some of that in the code.
A small fetch from a repo with 580 packfiles, which before this change
took around 48s, takes around 33s after this change. This fetch results
in the same pack file, bit for bit, before and after this change.
Change-Id: Iece58e0f2f6d04d8d302374428364547023a50f8
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |\ |
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
See e.g. https://knowthecode.io/yoda-conditions-yoda-not-yoda
Change-Id: I1f9021305699bfcfea3ac45ad0a609b627e0e898
|
|\ \ \ \ \ \ \ |
|
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | |
to support use cases which want to use try-with-resources with the Git
object so that closing the Git object also closes the wrapped
repository.
Bug: jgit-195
Change-Id: I69d432e2da2f3d3ebd91865e25c06da4e03e75fd
|
|/ / / / / / /
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
Suppress errors on closing the input stream in a fetch. If the fetch
itself worked and didn't throw an exception, then we don't care about
exceptions on closing the input stream. Just log the exception at debug
level.
It appears that in particular some Azure git servers may do things that
cause an exception in Apache HTTP on closing its ChunkedInputStream.[1]
The JDK's equivalent ChunkedInputStream ignores exceptions at that
place,[2] which explains why fetching with the JDK HTTP support works,
while it sometimes fails with Apache HTTP.
[1] https://github.com/apache/httpcomponents-core/blob/a5c117028b7c620974304636d52f06f172f1d08b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java#L306
[2] https://github.com/openjdk/jdk/blob/1a206d2a6cade07249f6922072ac9d29aa56bc43/src/java.base/share/classes/sun/net/www/http/ChunkedInputStream.java#L785
Bug: jgit-59
Change-Id: Ic26f0188f4f2ed9318f01ccfe2f93c3596950197
|
|\| | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* stable-7.3:
Use volatiles for bitmap and revIndex in Pack
Fix performance regression in Pack.idx()
Use LocalObjectToPack representation more
Use representation from LocalObjectToPack if possible
Avoid conditional in LocalObjectRepresentation.wasDeltaAttempted
Change-Id: Ibbc5b439b721a6d0267b6c70c0370f7a9fe7f74c
|
| |\| | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* stable-7.2:
Use volatiles for bitmap and revIndex in Pack
Fix performance regression in Pack.idx()
Use LocalObjectToPack representation more
Use representation from LocalObjectToPack if possible
Avoid conditional in LocalObjectRepresentation.wasDeltaAttempted
Change-Id: I30ad67c728b406be05ed1c77a5d6e78eecf73a79
|
| | |\| | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* stable-7.1:
Use volatiles for bitmap and revIndex in Pack
Fix performance regression in Pack.idx()
Use LocalObjectToPack representation more
Use representation from LocalObjectToPack if possible
Avoid conditional in LocalObjectRepresentation.wasDeltaAttempted
Change-Id: I38dabec5d9c56201bc895fe5019e7447520cb260
|
| | | |\| | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* stable-7.0:
Use volatiles for bitmap and revIndex in Pack
Fix performance regression in Pack.idx()
Use LocalObjectToPack representation more
Use representation from LocalObjectToPack if possible
Avoid conditional in LocalObjectRepresentation.wasDeltaAttempted
Change-Id: I953fec9bac3843845fe641af77ab9b757b2638ad
|
| | | | |\| |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* stable-6.10:
Use volatiles for bitmap and revIndex in Pack
Fix performance regression in Pack.idx()
Use LocalObjectToPack representation more
Use representation from LocalObjectToPack if possible
Avoid conditional in LocalObjectRepresentation.wasDeltaAttempted
Change-Id: If7e45204cc033506745ee394cc6119c1ad8dfb3b
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
Previously idx() was memoized with a volatile to improve performance, do
the same for the bitmap and reverseIndexes.
Change-Id: I50515a3aaae7dd4f9d23989dcd5f79cefc9e0f07
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |/
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
A threading bug fixed with ae53d63837857d886cdf15442118597be717ff33
introduced a performance regression as it used a synchronized idx() for
every call. Fix this by only requiring the synchronized when the index
has yet to be, or is no longer, memoized. Use a volatile instead of a
synchronized in the fast case, and avoid calling Optionally.clear()
since we no longer access the field from only synchronized blocks.
Instead, replace the volatile value with an Optinonally.Empty avoiding
the need to replace an internal Optionally field in an unguarded manner.
In some single fetch cases this speeds things up from 48s to 44s. In a 5
concurrent parallel fetch test, this speeds things up from 2min10s to
1min21s!
Change-Id: I73a62a8b861b343b112699537e8c947db8159e44
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Use LOTP to also get size in ObjectDirectory. This path is use when
searching for deltas, however I cannot find an obvious testable
improvement for this. I suspect that this would do best on a fetch with
very few reuseable deltas.
Change-Id: Ifae154332e3599f77fd9c9bdcf7e1ad3f5055398
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
When PackWriter selects an ObjectRepresentation, it will select a
representation if it doesn't have a better one already selected, even if
it clears ReuseAsIs from the LocalObjectToPack (presumably so that it
always has a pointer to at least one copy of the object). Previously,
the LocalObjectToPack representation was only used if it was marked as
ReuseAsIs. Improve this to reuse this representation, if it is still
there, even if it cannot be reused as is, since it can at least be used
as the representation, when opening an object in ObjectDirectory to send
it for the PackWriter as "wholeDeflated". This avoids an unnecessary
search of the existing pack files, which can be expensive when there are
many pack files in a repo, just to find any (the first in the directory)
copy of this object.
On a repo with around 580 packfiles, this change will reduce a fetch
which normally takes around 44s to around 41s.
Change-Id: I16ec71d0cc447166bf4b89e94abecbf0aeee7f44
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
LocalObjectRepresentation is overriden for both a delta and for a whole
object already, which means in these cases, the outcome of the base
wasDeltaAttempted logic is fixed as it depends on the output of
getFormat() which is hardcoded in these overriden objects. Hardcode this
outcome also in the overriden classes to avoid a useless conditional in
a hotpath.
This change takes about 1s off of a 31s fetch.
Change-Id: Ic06c40504875d9868c6072d488e68248538d4f65
Signed-off-by: Martin Fick <mfick@nvidia.com>
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
The object size index has the size of all blobs over certain threshold
already in memory. For these objects, it should be faster to read the
size from this index than going to storage (IO).
Use the index when available and possible inside #getObjectSize() (which
returns the exact size of the object) and #isSmallerThan() (which is a
more relaxed check that the size is below certain threshold).
Change-Id: Iae9ff8848c236be21ca3dbe5606cbd29409de608
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Write the object size index if configuration says so. Include the new
size index file in the preservation list, so it gets copied when needed.
Add the number of objects in the size index to the stats. This is useful
for testing/debugging. Tests are the relevant cases from
GcBasicPackingTest, asserting the object-size presence/size.
Change-Id: I8d937aafc3e584ce3c0ffb0f17c852efea946a78
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
ObjectDirectoryPack{Parser,Inserter} is not symmetrical to the
Pack{Parser,Inserter} combination. In the Pack* version, the inserter
takes care of writing the indices on #flush. In the ObjectDirectory*
size, this is done by the parser.
Make ObjectDirectoryPackParser write the object size index.
Change-Id: I5a1c091857928b141a07920a5c10e931ffe9bfa2
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Create an object-index when writing a pack with PackInserter if config
says so.
Change-Id: Ic7a3a92b8f8afc4d89e37b9bf8091f438fa9b8c1
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
In some cases (e.g. filtering objects in a partial clone), the caller
prefers the faster (but optional) indexed size rather than the slower
read from storage.
Expose the indexed size in Pack. The caller must check that the pack
has index (with #hasObjectSizeIndex()) and ask only for objects in that
pack.
Change-Id: Ia04e40250a8fb4890ae556ace516944d191f24ef
|
|\| | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* stable-7.3:
Lock reftable auto-refresh to ensure consistency
Change-Id: I43df38f98f0b03dec2e64d4c52257ddc3affd64f
|
| |\| | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* stable-7.2:
Lock reftable auto-refresh to ensure consistency
Change-Id: I9219f0fd606b2eb6b9a0632375934f51f1f4c547
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Ensure that reftable auto-refresh operations, clearing the database
cache and reloading the reftable stack are executed in an exclusive
critical section under lock. Previously, these steps were performed
without an exclusive critical section, creating a window where
concurrent threads could interfere with each other.
In a race condition, one thread might clear the cache and before it had
a chance of reloading the stack, another thread could repopulate the
cache with stale data, keeping a reference to the open BlockSource
channel to the underlying tables that are subsequently removed when the
first thread reloads the stack.
The above race condition resulted in attempts to access closed resources
and lead to ClosedChannelException errors.
As an example, consider the following scenario:
* T0 - Thread-1 is executing auto-refresh and it clears the database
cache
* T1 - The master branch moves forward (for any reason):
- A new refTable (`R_new`) file is created
- An existing refTable (`R_old`) file is deleted due to
auto-compaction.
* T3 - Thread-2 repopulates the database cache before Thread-1 has had a
chance to reload the refTable stack.
* T4 - Thread-1 finally reloads the refTable stack, causing the closing
of the BlockSource wrapping the removed `R_old` refTable file.
* T5 - Thread-2 attempts to read from the already-closed `R_old`
BlockSource and the `j.n.c.ClosedChannelException` is thrown
To reproduce this problem, you can run a script created to craft this
racing condition: I1e78e175cff.
While such errors during concurrent execution might be expected and
tolerable in isolation, the situation becomes more severe when the
`RepositoryCache` is involved, as is the case with Gerrit.
The `FileReftableDatabase` instance is cached within the `Repository`
object. When a `BlockSource` is closed prematurely due to this race
condition, the dangling reference remains in memory until the cached
Repository expires, which is one hour by default.
This means that, once the race occurs, the repository may be unable to
perform any ref lookups for up to an hour, effectively causing a
repository outage.
By introducing a ReentrantLock around both operations, the refresh logic
now guarantees that concurrent readers and writers maintain a consistent
view of the reftable state, eliminating the race condition.
Verified by executing the script provided at I1e78e175cff and no
exceptions are raised anymore.
Bug: jgit-130
Change-Id: I6153528a7b2695115b670bda04d4d4228c1731e1
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
PackList is an abstract class with two implementations, the default
PackListImpl (never dirty) and NO_PACKS (always dirty).
Simplify this to a class (PackList) with an special implementation for
NO_PACKS.
Change-Id: Ie97e1084417bbfa15c46bd570121a83883ed183c
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
There are no callers for markDirty(), so in NO_PACKS dirty is always
true and in the PackListImpl is always false. clearDirty() is a noop
in both cases.
Delete these methods to avoid confusions.
Change-Id: I74d02be7dc287bef27fb7b9d6588c8d8c74105a8
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This method is inneficient, as callers lookup the object in the
primary index twice: once to find it is in the pack (before calling),
another for the position (in the method). Now we have
\#getIndexedObjectSize(ctx, indexPosition) variant, so callers find the
pack with \#findIdxPosition() and reuse the idxPosition here.
Remove this variant with objectId. It doesn't do anything that the
combination above cannot do.
Change-Id: Ia913f511338b44ab5c45c55d47754d299946f03c
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Reported as warning in the mvn build.
Change-Id: I981947c5717b74ef9547322b25a7211337b32cf6
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
mvn build was warning about these messages lacking the NLS
annotation.
As the method has 3 lines with 3 string, just suppress the
warning in the whole method.
Change-Id: I0dbd4055266517edd21418dc12528776078c34cc
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
To get the indexed size of an object, we do two lookups in the primary
index. First to find the object, then to find its position in the
index. This hits performance when checking many object sizes on big
packs.
The first lookup of the object returns the index position. Reuse it
for the object size index.
Change-Id: If875d1b5d0b70f0cf4c448e0f9da09db65caac5e
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Now findPack does the same than findPackWithObject, but it also returns
the index position of the object, which we wil use in the next change.
In getObjectSize and isNotLargerThan, use "findPack" to lookup the
object. There are no more usages of findPackWithObject.
Change-Id: I9d26a1bf4ac4e8f87148be90e25d17efa4b70e69
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This is a preparatory change to avoid double lookup in the primary
index when using the object size index. If we get the index position
during the object lookup, we dont need to query the index again when
looking up the size.
Make "hasImpl" return the index position of the object in the
pack (besides leaving "last" pointing to the pack). Move the "has"
logic that checks "last" before other packs to a method we can reuse.
Change-Id: I36d2b348971a642c54da3d3727c04d0134ca9eba
|
|/ / / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
safeGetIndexedObjectSize returns an Optional to differentiate
between "object not found in index" and "index not found". This is
wrong for two reasons: the IOException indicating "index not found" is only thrown
once (on first loading failure) and the first loading happens in
the "hasObjectSizeIndex" just before.
Rethrow the IOException in getIndexesObjectSize as
IllegalStateException (as it shouldn't happen) and return a plain long
in the call.
As a side, this saves instantiating an Optional per call and
simplifies further optimizations.
Change-Id: Ic728483f0e1ec7f98495fdbdb15dc0b24f30dbfd
|
|\| | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.2:
Fix: Close the "preserved" PackDirectory
Change-Id: If9f2cd1278aad72f6ca7cae72fbd6b9f5ec66bc8
|
| |\| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.1:
Fix: Close the "preserved" PackDirectory
Change-Id: I82f138f134fe09717e2e024b3c87971140f01b29
|
| | |\| |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.0:
Fix: Close the "preserved" PackDirectory
Change-Id: Icd3f79322f8c021e18fd5c881cd9f2a406230fa8
|
| | | |\|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-6.10:
Fix: Close the "preserved" PackDirectory
Change-Id: Ie0ecfd8178ef4e2eef6a29d46be5645648fe88f3
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This has been missing since the feature was first added in commit
6167641834e28f8ad322f8fde60866b339bfb7fe.
It's possible we could be more aggressive and close soon after
attempting to get an object from the preserved packs, but for concurrent
misses that might cause thrashing. More likely it would be safe to
attempt closing after successfully restoring a preserved pack. A follow
up change should attempt that.
Change-Id: I87d61007bcc3d03fc86bd18465ca66a2e6f697a1
|
|\| | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.2:
Use the same ordering/locking in delete() as C git
Change-Id: I0b583cd218c39b1dc0726ae82da86eca58cc81eb
|
| |\| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.1:
Use the same ordering/locking in delete() as C git
Change-Id: Id52c938b041604162dca9162726bfb594e96f5d1
|
| | |\| |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-7.0:
Use the same ordering/locking in delete() as C git
Change-Id: I2c38321ee410d9ec60481d56315710beaebd393a
|
| | | |\|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* stable-6.10:
Use the same ordering/locking in delete() as C git
Change-Id: I0d06e39d06315e0b9e770bdf79164779d98f9f50
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Following the examples of cgit, lock packed-refs *before* checking for
existance of refs in it [1] and *keep the lock* until the loose ref (if
any) is removed [2]. The packed-refs lock is kept even when no
packed-refs update is required [3] so that somebody else doesn't pack a
reference that we are trying to delete.
This fixes a concurrency issue that happens on projects with a
substantial amount of refs(>~500k) where packing takes long enough for a
ref deletion to be triggered half way through it. Not locking the
packed-refs file before checking if the refs exists is not safe, as it
opens up situations where loose refs are repacked in memory and locked
on disk, but before the lock is released and packed-refs is flushed to
disk, a ref is deleted.
As packed-refs was NOT locked while checking wether a ref existed in it,
the current content on disk was read, which was about to be overwritten
and did not contain the ref about to be deleted. As the delete doesn't
see the ref in the current, on-disk, version of packed refs, it skips
processing altogether and moves on, correctly, deleting only the
associated loose ref and leaving the packed one behind.
Once the new packed-refs, containing the ref that was just deleted, was
commited to disk, the ref would come back to life.
Therefore, the packed-refs needs to be locked before checking if it
contains a ref or not in the same way the C implementation of Git does
at [1].
There are tradeoffs, though, in this decision, which will reduce the
parallelism of deleting loose refs and performing the refs repacking,
which happens very often in certain JGit implementations like Gerrit
Code Review. Before this change, repacking of refs and removal of loose
refs unrelated to the in-flight repacking was possible without involving
any locking; after this change, all loose refs removals have to wait for
the packing of refs to be completed, even though the repacking and the
refs removals were completely unrelated and their namespaces disjoint.
See more details on the test's performance results and the associated
tradeoffs in the Issue jgit-152.
NOTE: This delete ref locking logic was incorrect regardless of how the
packing of the refs is implemented. Making decisions if the pack
transaction is needed or not on an unlocked resource is racy and also
flagged as bug at [1].
[1]https://github.com/git/git/blob/master/refs/packed-backend.c#L1590
[2]https://github.com/git/git/blob/master/refs/files-backend.c#L3261
[3]https://github.com/git/git/blob/master/refs/files-backend.c#L2943
Bug: jgit-152
Change-Id: I158ec837904617c5fdf667e295ae667b2f037945
|