Bug P1
Status Update
Comments
ba...@gmail.com <ba...@gmail.com> #2
Comment has been deleted.
ba...@gmail.com <ba...@gmail.com> #3
Comment has been deleted.
ap...@google.com <ap...@google.com> #4
Project: gerrit
Branch: master
Author: Luca Milanesio <
Link:
Fix Repository reference counting by auto-closing RepoView after use
Expand for full commit details
Fix Repository reference counting by auto-closing RepoView after use
The RepoView wrapper is based on Repository and increments its
reference counting to prevent it from being released by the JGit's
RepositoryCache.
Although the close() method was implemented from the very beginning
in I17a77a1f9, it was not called consistently by all consumers,
creating a situation where the Repository reference counting was
increased by one every time that a new RepoView was created.
Add all the missing close() calls in every place where the RepoView
is used so that the reference counting of the Repository after use
returns to zero after the operation has been completed.
Having a consistent reference counting in the JGit RepositoryCache
allows to honour the RepositoryCache's settings for closing the
repositories upon expiry.
Another benefit of having consistent reference counting is also the
release of the JVM heap once a repository isn't used anymore for a
long period of time, reducing the memory pressure and the amount of
JVM GC cycles. Lastly, when a Repository is released from the
JGit's RepositoryCache, its blocks are released from the JGit's
WindowCache, allowing more space to be used for other repositories
more frequently used.
Release-Notes: Fix the reference counting for a correct release of repositories from the JGit in-memory repository cache
Bug: Issue 392541994
Change-Id: I2d93b9f30d2fea957e6090d10101a520ef0365b1
Files:
- M
java/com/google/gerrit/server/approval/ApprovalCopier.java
- M
java/com/google/gerrit/server/git/receive/ReceiveCommits.java
- M
java/com/google/gerrit/server/patch/AutoMerger.java
- M
java/com/google/gerrit/server/patch/DiffOperationsImpl.java
- M
javatests/com/google/gerrit/acceptance/server/change/ApprovalCopierIT.java
- M
javatests/com/google/gerrit/acceptance/server/query/ApprovalQueryIT.java
- M
javatests/com/google/gerrit/server/patch/DiffOperationsTest.java
Hash: 16e451bac012a3027527a7ea967d4dff7752cd55
Date: Sun Jan 26 11:38:04 2025
ma...@gmail.com <ma...@gmail.com> #5
With
Description
*** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!! *** Do not submit bugs for chrome/android and issues with your company's *** Gerrit setup here. Those issues belong in different issue trackers.
What steps will reproduce the problem?
core.repositoryCacheExpireAfter=1
andcore.repositoryCacheCleanupDelay=1
)testrepo
with a ref-table, which keeps files open as long as the repository is opengit push origin HEAD:refs/for/master
What is the expected output?
After the change is created, Gerrit should not hold any reference to the ref-table files
What do you see instead?
Gerrit still holds references to the ref-table files.
Please provide any additional information below.
The issue is related to the reference counting: in many places in Gerrit the objects wrapping the repositories aren't closed properly, causing the reference number to increase and never coming back to zero.
That causes two issues: a) The ref-table files are always open b) The repositories are never released, causing also memory leak in Gerrit JVM heap
Bottom line is: without a proper fix to this problem the ref-table is pretty much unusable, as the repository will stay open indefinitely and the ref-table files will very quickly become stale and unreadable.