diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-12-07 17:37:48 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-12-09 12:51:32 +0300 |
commit | 58cc4948bad1a3e51be3740eea2b61b9f9f1c345 (patch) | |
tree | 8088a5921943599dfbf956159161296960f3ef60 | |
parent | dc17627aeba0607f00330404bf1ae7311f213c0b (diff) |
objectpool: Perform housekeeping
When performing garbage collection on repositories, we always call our
housekeeping tasks to rid the repository of any files which we know
shouldn't be there anymore. This ensures we remove stale files which
only take up precious disk space, but it also in some cases ensures that
we're removing files which may cause git to malfunction. One such case
is for example empty references which may be created under some
circumstances during hard reboots or crashes.
While we do this for repositories, we don't do so for our object pools.
This is causing hard to spot issues with repositories not getting
updated or not getting repacked. After a while, this leads to a
deterioration of performance when cloning repositories which are part of
such a pool.
There isn't any place where we currently perform garbage collection, but
the next-best place is `FetchFromOrigin()`. Next to pulling in new
objects from the source repository, it also packs references and checks
for repository consistency. So let's use it to also perform our
housekeeping tasks for object pools here.
-rw-r--r-- | changelogs/unreleased/pks-object-pool-housekeeping.yml | 5 | ||||
-rw-r--r-- | internal/git/objectpool/fetch.go | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/changelogs/unreleased/pks-object-pool-housekeeping.yml b/changelogs/unreleased/pks-object-pool-housekeeping.yml new file mode 100644 index 000000000..9c3f0be0d --- /dev/null +++ b/changelogs/unreleased/pks-object-pool-housekeeping.yml @@ -0,0 +1,5 @@ +--- +title: Perform housekeeping for object pools +merge_request: 2885 +author: +type: added diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go index 4ac559962..41967d029 100644 --- a/internal/git/objectpool/fetch.go +++ b/internal/git/objectpool/fetch.go @@ -15,6 +15,7 @@ import ( "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" + "gitlab.com/gitlab-org/gitaly/internal/git/housekeeping" "gitlab.com/gitlab-org/gitaly/internal/git/repository" "gitlab.com/gitlab-org/gitaly/internal/git/updateref" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -33,11 +34,14 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *gitalypb.Repos } originPath, err := o.locator.GetPath(origin) - if err != nil { return err } + if err := housekeeping.Perform(ctx, originPath); err != nil { + return err + } + opts := []git.CmdOpt{ git.WithRefTxHook(ctx, helper.ProtoRepoFromRepo(o), o.cfg), } |