diff options
author | Toon Claes <toon@gitlab.com> | 2020-12-01 15:18:14 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2020-12-01 18:23:09 +0300 |
commit | c854b74ed7ae0af2ee2a9ccc0320ebfc90bc31b1 (patch) | |
tree | 3f3f36923c40e854df678ac344888f6233c23702 /internal/praefect/replicator.go | |
parent | 3154e9cb4c1df03c5405e2bd8a429838ebde03f2 (diff) |
No longer compare checksums after replication
Prior to this change, the checksums of primary and replica were
calculated after completing the replication. In some cases, i.e. when
the primary did receive more updates after replication was initiated,
these checksums did not match.
This change removes the checksum calculation and comparison because it
was only added for demos in the first place. Removing this checksumming
will reduce load on the cluster.
Closes https://gitlab.com/gitlab-org/gitaly/-/issues/3110
Diffstat (limited to 'internal/praefect/replicator.go')
-rw-r--r-- | internal/praefect/replicator.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/internal/praefect/replicator.go b/internal/praefect/replicator.go index dbabb899e..039c4c4ee 100644 --- a/internal/praefect/replicator.go +++ b/internal/praefect/replicator.go @@ -13,11 +13,9 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/middleware/metadatahandler" "gitlab.com/gitlab-org/gitaly/internal/praefect/config" "gitlab.com/gitlab-org/gitaly/internal/praefect/datastore" - "gitlab.com/gitlab-org/gitaly/internal/praefect/metrics" prommetrics "gitlab.com/gitlab-org/gitaly/internal/prometheus/metrics" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/labkit/correlation" - "golang.org/x/sync/errgroup" "google.golang.org/grpc" ) @@ -124,21 +122,6 @@ func (dr defaultReplicator) Replicate(ctx context.Context, event datastore.Repli } } - checksumsMatch, err := dr.confirmChecksums(ctx, logger, gitalypb.NewRepositoryServiceClient(sourceCC), targetRepositoryClient, sourceRepository, targetRepository) - if err != nil { - return err - } - - // TODO: Do something meaninful with the result of confirmChecksums if checksums do not match - if !checksumsMatch { - metrics.ChecksumMismatchCounter.WithLabelValues( - targetRepository.GetStorageName(), - sourceRepository.GetStorageName(), - ).Inc() - - logger.Error("checksums do not match") - } - if generation != datastore.GenerationUnknown { return dr.rs.SetGeneration(ctx, event.Job.VirtualStorage, @@ -287,39 +270,6 @@ func (dr defaultReplicator) RepackFull(ctx context.Context, event datastore.Repl return err } -func getChecksumFunc(ctx context.Context, client gitalypb.RepositoryServiceClient, repo *gitalypb.Repository, checksum *string) func() error { - return func() error { - primaryChecksumRes, err := client.CalculateChecksum(ctx, &gitalypb.CalculateChecksumRequest{ - Repository: repo, - }) - if err != nil { - return err - } - *checksum = primaryChecksumRes.GetChecksum() - return nil - } -} - -func (dr defaultReplicator) confirmChecksums(ctx context.Context, logger logrus.FieldLogger, primaryClient, replicaClient gitalypb.RepositoryServiceClient, primary, replica *gitalypb.Repository) (bool, error) { - g, gCtx := errgroup.WithContext(ctx) - - var primaryChecksum, replicaChecksum string - - g.Go(getChecksumFunc(gCtx, primaryClient, primary, &primaryChecksum)) - g.Go(getChecksumFunc(gCtx, replicaClient, replica, &replicaChecksum)) - - if err := g.Wait(); err != nil { - return false, err - } - - logger.WithFields(logrus.Fields{ - "primary_checksum": primaryChecksum, - "replica_checksum": replicaChecksum, - }).Info("checksum comparison completed") - - return primaryChecksum == replicaChecksum, nil -} - // ReplMgr is a replication manager for handling replication jobs type ReplMgr struct { log *logrus.Entry |