Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Tobler <jtobler@gitlab.com>2023-07-05 19:56:45 +0300
committerJustin Tobler <jtobler@gitlab.com>2023-07-05 21:54:50 +0300
commitd986ecaba04cecddbe46c26e5e9da5759f5f9cb7 (patch)
tree3215121cdc6fb4e8c186ab7c2637e3e682f2c22e
parent35700521a663370c7f8f2767b53e5c3440f2e675 (diff)
git: Remove `GeometricRepackingSupportsAlternates()`
The `GeometricRepackingSupportsAlternates()` function detects whether the given Git version knows to perform geometric repacking in repositories which are connected to an alternate object database. Since the required minimum Git version has been increased to v2.41, this check always returns true. Remove the function and clean up its call sites.
-rw-r--r--internal/git/housekeeping/optimization_strategy.go17
-rw-r--r--internal/git/housekeeping/optimization_strategy_test.go30
-rw-r--r--internal/git/housekeeping/optimize_repository_test.go25
-rw-r--r--internal/git/version.go16
-rw-r--r--internal/git/version_test.go27
5 files changed, 13 insertions, 102 deletions
diff --git a/internal/git/housekeeping/optimization_strategy.go b/internal/git/housekeeping/optimization_strategy.go
index 37775bca3..7ac3563f7 100644
--- a/internal/git/housekeeping/optimization_strategy.go
+++ b/internal/git/housekeeping/optimization_strategy.go
@@ -62,22 +62,7 @@ func (s HeuristicalOptimizationStrategy) ShouldRepackObjects(ctx context.Context
return false, RepackObjectsConfig{}
}
- // There is a bug in Git that causes geometric repacking to fail in some circumstances when
- // the repository is connected to an object pool. While we're upstreaming the fix via
- // https://gitlab.com/gitlab-org/git/-/issues/152 we thus disable geometric repacks in any
- // repository that has alternates.
- //
- // While this is kind of annoying, it ultimately shouldn't be too bad in most contexts as
- // the majority of objects of a repository with object pool should be in the object pool
- // anyway. We should eventually remove this condition though once the fix has landed.
- //
- // We have upstreamed fixes for this that are about to arrive in Git v2.41. Furthermore, we
- // have backported them into Git v2.40.0.gl1. So if we detect that the current Git version
- // does indeed support geometric repacking then we can enable this even when the repository
- // is part of an object pool.
- canUseGeometricRepacking := len(s.info.Alternates.ObjectDirectories) == 0 || s.gitVersion.GeometricRepackingSupportsAlternates()
-
- if canUseGeometricRepacking && featureflag.GeometricRepacking.IsEnabled(ctx) {
+ if featureflag.GeometricRepacking.IsEnabled(ctx) {
nonCruftPackfilesCount := s.info.Packfiles.Count - s.info.Packfiles.CruftCount
timeSinceLastFullRepack := time.Since(s.info.Packfiles.LastFullRepack)
diff --git a/internal/git/housekeeping/optimization_strategy_test.go b/internal/git/housekeeping/optimization_strategy_test.go
index 165f38ff2..7075300f7 100644
--- a/internal/git/housekeeping/optimization_strategy_test.go
+++ b/internal/git/housekeeping/optimization_strategy_test.go
@@ -76,7 +76,10 @@ func testHeuristicalOptimizationStrategyShouldRepackObjects(t *testing.T, ctx co
// exist in pooled repositories.
expectedNeeded: true,
expectedConfig: RepackObjectsConfig{
- Strategy: RepackObjectsStrategyIncremental,
+ Strategy: geometricOrIncremental(ctx,
+ RepackObjectsStrategyGeometric,
+ RepackObjectsStrategyIncremental,
+ ),
WriteMultiPackIndex: true,
},
},
@@ -383,31 +386,6 @@ func testHeuristicalOptimizationStrategyShouldRepackObjects(t *testing.T, ctx co
),
},
{
- desc: "no geometric repack in object pool member with old Git version",
- strategy: HeuristicalOptimizationStrategy{
- gitVersion: git.NewVersion(2, 39, 0, 0),
- info: stats.RepositoryInfo{
- Packfiles: stats.PackfilesInfo{
- Count: 9,
- LastFullRepack: time.Now(),
- MultiPackIndex: stats.MultiPackIndexInfo{
- Exists: true,
- PackfileCount: 1,
- },
- },
- Alternates: stats.AlternatesInfo{
- ObjectDirectories: []string{"object-pool"},
- },
- },
- },
- expectedNeeded: true,
- expectedConfig: RepackObjectsConfig{
- Strategy: RepackObjectsStrategyFullWithCruft,
- WriteBitmap: false,
- WriteMultiPackIndex: true,
- },
- },
- {
desc: "geometric repack in object pool member with recent Git version",
strategy: HeuristicalOptimizationStrategy{
gitVersion: git.NewVersion(2, 40, 0, 1),
diff --git a/internal/git/housekeeping/optimize_repository_test.go b/internal/git/housekeeping/optimize_repository_test.go
index dad4830fa..84b878f29 100644
--- a/internal/git/housekeeping/optimize_repository_test.go
+++ b/internal/git/housekeeping/optimize_repository_test.go
@@ -457,9 +457,6 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
cfg := testcfg.Build(t)
txManager := transaction.NewManager(cfg, backchannel.NewRegistry())
- gitVersion, err := gittest.NewCommandFactory(t, cfg).GitVersion(ctx)
- require.NoError(t, err)
-
earlierDate := time.Date(2022, 12, 1, 0, 0, 0, 0, time.Local)
laterDate := time.Date(2022, 12, 1, 12, 0, 0, 0, time.Local)
@@ -489,11 +486,6 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
geometricOrIncrementalMetric := geometricOrIncremental(ctx, "packed_objects_geometric", "packed_objects_incremental")
- geometricIfSupported := geometricOrIncrementalMetric
- if !gitVersion.GeometricRepackingSupportsAlternates() {
- geometricIfSupported = "packed_objects_incremental"
- }
-
type metric struct {
name, status string
count int
@@ -836,7 +828,7 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
return setupData{
repo: localrepo.NewTestRepo(t, cfg, repo),
expectedMetrics: []metric{
- {name: geometricIfSupported, status: "success", count: 1},
+ {name: geometricOrIncrementalMetric, status: "success", count: 1},
{name: "written_commit_graph_full", status: "success", count: 1},
{name: "written_multi_pack_index", status: "success", count: 1},
{name: "total", status: "success", count: 1},
@@ -892,7 +884,7 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
return setupData{
repo: localrepo.NewTestRepo(t, cfg, repo),
expectedMetrics: []metric{
- {name: geometricIfSupported, status: "success", count: 1},
+ {name: geometricOrIncrementalMetric, status: "success", count: 1},
{name: "written_commit_graph_full", status: "success", count: 1},
{name: "written_multi_pack_index", status: "success", count: 1},
{name: "total", status: "success", count: 1},
@@ -928,12 +920,11 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
{name: "total", status: "success", count: 1},
},
expectedMetricsForPool: []metric{
- {name: func() string {
- if gitVersion.GeometricRepackingSupportsAlternates() {
- return geometricOrIncremental(ctx, "packed_objects_full_with_unreachable", "packed_objects_full_with_loose_unreachable")
- }
- return "packed_objects_full_with_loose_unreachable"
- }(), status: "success", count: 1},
+ {
+ name: geometricOrIncremental(ctx, "packed_objects_full_with_unreachable", "packed_objects_full_with_loose_unreachable"),
+ status: "success",
+ count: 1,
+ },
{name: "written_multi_pack_index", status: "success", count: 1},
{name: "total", status: "success", count: 1},
},
@@ -1015,7 +1006,7 @@ func testOptimizeRepository(t *testing.T, ctx context.Context) {
return setupData{
repo: localrepo.NewTestRepo(t, cfg, repo),
expectedMetrics: []metric{
- {name: geometricIfSupported, status: "success", count: 1},
+ {name: geometricOrIncrementalMetric, status: "success", count: 1},
{name: "written_commit_graph_full", status: "success", count: 1},
{name: "written_multi_pack_index", status: "success", count: 1},
{name: "total", status: "success", count: 1},
diff --git a/internal/git/version.go b/internal/git/version.go
index 1c263f6f8..831ac3029 100644
--- a/internal/git/version.go
+++ b/internal/git/version.go
@@ -75,22 +75,6 @@ func (v Version) IsSupported() bool {
return !v.LessThan(minimumVersion)
}
-// GeometricRepackingSupportsAlternates detects whether the given Git version knows to perform
-// geometric repacking in repositories which are connected to an alternate object database. This
-// used to not work due to various different bugs which have been fixed via de56e80363 (Merge branch
-// 'ps/fix-geom-repack-with-alternates' into next, 2023-04-18).
-//
-// The patches will be part of Git v2.41.0 and have been backported to Git v2.40.0.gl1.
-func (v Version) GeometricRepackingSupportsAlternates() bool {
- if v.major == 2 && v.minor == 40 && v.gl > 0 {
- return true
- }
-
- return !v.LessThan(Version{
- major: 2, minor: 41,
- })
-}
-
// CatfileSupportsNulTerminatedOutput detects whether git-cat-file(1) knows the `-Z` switch, which causes it to
// NUL-terminate both stdin and stdout. This new switch has been introduced upstream via a9ea4c23dc (Merge branch
// 'ps/cat-file-null-output', 2023-06-22).
diff --git a/internal/git/version_test.go b/internal/git/version_test.go
index 4df719139..83af74e3c 100644
--- a/internal/git/version_test.go
+++ b/internal/git/version_test.go
@@ -126,33 +126,6 @@ func TestVersion_IsSupported(t *testing.T) {
}
}
-func TestVersion_GeometricRepackingSupportsAlternates(t *testing.T) {
- t.Parallel()
-
- for _, tc := range []struct {
- version string
- expect bool
- }{
- {"1.0.0", false},
- {"2.39.2", false},
- {"2.40.0", false},
- {"2.40.1", false},
- {"2.40.0.gl1", true},
- {"2.40.0.gl2", true},
- {"2.40.1.gl1", true},
- {"2.40.1.gl2", true},
- {"2.41.0", true},
- {"3.0.0", true},
- } {
- t.Run(tc.version, func(t *testing.T) {
- version, err := parseVersion(tc.version)
- require.NoError(t, err)
- require.Equal(t, tc.expect,
- version.GeometricRepackingSupportsAlternates())
- })
- }
-}
-
func TestVersion_CatfileSupportsNulTerminatedOutput(t *testing.T) {
t.Parallel()