Skip to content
Snippets Groups Projects
Commit d76ced60 authored by Patrick Steinhardt's avatar Patrick Steinhardt
Browse files

housekeeping: Replace commit-graph chain when missing generation data

Git will only read and write generation data from commit-graphs when the
complete chain of graphs already has generation data. As a result, when
we incrementally append a new commit-graph slice to the chain of graphs
we won't generate the commit-graph data at all.

We have essentially the same problem with bloom filters, where the
current strategy is to just rewrite the complete commit-graph chain in
case the chain is missing bloom filters. So let's do the same when they
are missing generation data.

Changelog: added
parent e77e552b
No related merge requests found
......@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
)
......@@ -45,6 +46,9 @@ func WriteCommitGraphConfigForRepository(ctx context.Context, repo *localrepo.Re
// ain't got bloom filters enabled. This is because Git will refuse to write any
// bloom filters as long as any of the commit-graph slices is missing this info.
replaceChain = true
} else if !commitGraphInfo.HasGenerationData && featureflag.UseCommitGraphGenerationData.IsEnabled(ctx) {
// The same is true for generation data.
replaceChain = true
}
return WriteCommitGraphConfig{
......
package housekeeping
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
)
func TestWriteCommitGraphConfigForRepository(t *testing.T) {
t.Parallel()
testhelper.NewFeatureSets(featureflag.UseCommitGraphGenerationData).Run(t, testWriteCommitGraphConfigForRepository)
}
func testWriteCommitGraphConfigForRepository(t *testing.T, ctx context.Context) {
t.Parallel()
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
for _, tc := range []struct {
......@@ -62,10 +68,26 @@ func TestWriteCommitGraphConfigForRepository(t *testing.T) {
},
},
{
desc: "split commit-graph with bloom filter",
desc: "split commit-graph with bloom filter without generation data",
setup: func(t *testing.T, repoPath string) {
gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
gittest.Exec(t, cfg, "-C", repoPath,
"-c", "commitGraph.generationVersion=1",
"commit-graph", "write", "--reachable", "--split", "--changed-paths",
)
},
expectedConfig: WriteCommitGraphConfig{
ReplaceChain: featureflag.UseCommitGraphGenerationData.IsEnabled(ctx),
},
},
{
desc: "split commit-graph with bloom filter with generation data",
setup: func(t *testing.T, repoPath string) {
gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
gittest.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
gittest.Exec(t, cfg, "-C", repoPath,
"-c", "commitGraph.generationVersion=2",
"commit-graph", "write", "--reachable", "--split", "--changed-paths",
)
},
expectedConfig: WriteCommitGraphConfig{
ReplaceChain: false,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment