diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-03-04 14:40:12 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-03-04 15:23:13 +0300 |
commit | 456e9a3ab51c515135b8b14b1822f96d820ade8e (patch) | |
tree | da8d364226952c55444ad4e9d5d90d0172d3d56c /internal/praefect/replicator.go | |
parent | 9c3d5914f9e4c888469c9ef6573b4c222e3a82b3 (diff) |
replicator: Do not bump repository generation for PackRefs
Similar in spirit to fc93593cb (praefect: Stop creating replication jobs
on cleanup, 2021-02-03), we're still bumping the repository generation
when creating PackRefs jobs. But given that these only optimize the
repository without changing the user-visible state of the repository,
bumping the repository generation is only going to needlessly cause us
to regard secondaries as out-of-date.
Fix the issue by introducing a separate "PackRefs" change type which
doesn't cause us to bump the generation.
Diffstat (limited to 'internal/praefect/replicator.go')
-rw-r--r-- | internal/praefect/replicator.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/praefect/replicator.go b/internal/praefect/replicator.go index 8e65d6757..794e39594 100644 --- a/internal/praefect/replicator.go +++ b/internal/praefect/replicator.go @@ -36,6 +36,8 @@ type Replicator interface { RepackIncremental(ctx context.Context, event datastore.ReplicationEvent, target *grpc.ClientConn) error // Cleanup will do a cleanup on the target repository Cleanup(ctx context.Context, event datastore.ReplicationEvent, target *grpc.ClientConn) error + // PackRefs will optimize references on the target repository + PackRefs(ctx context.Context, event datastore.ReplicationEvent, target *grpc.ClientConn) error } type defaultReplicator struct { @@ -273,6 +275,21 @@ func (dr defaultReplicator) Cleanup(ctx context.Context, event datastore.Replica return err } +func (dr defaultReplicator) PackRefs(ctx context.Context, event datastore.ReplicationEvent, targetCC *grpc.ClientConn) error { + targetRepo := &gitalypb.Repository{ + StorageName: event.Job.TargetNodeStorage, + RelativePath: event.Job.RelativePath, + } + + refSvcClient := gitalypb.NewRefServiceClient(targetCC) + + _, err := refSvcClient.PackRefs(ctx, &gitalypb.PackRefsRequest{ + Repository: targetRepo, + }) + + return err +} + func (dr defaultReplicator) RepackFull(ctx context.Context, event datastore.ReplicationEvent, targetCC *grpc.ClientConn) error { targetRepo := &gitalypb.Repository{ StorageName: event.Job.TargetNodeStorage, @@ -643,6 +660,8 @@ func (r ReplMgr) processReplicationEvent(ctx context.Context, event datastore.Re err = r.replicator.RepackIncremental(ctx, event, targetCC) case datastore.Cleanup: err = r.replicator.Cleanup(ctx, event, targetCC) + case datastore.PackRefs: + err = r.replicator.PackRefs(ctx, event, targetCC) default: err = fmt.Errorf("unknown replication change type encountered: %q", event.Job.Change) } |