From 73eb0f44c0484f4730ca334c9b27e8cd0ad9ec86 Mon Sep 17 00:00:00 2001 From: Sami Hiltunen Date: Tue, 10 Aug 2021 14:46:49 +0200 Subject: Don't schedule replication jobs in SetAuthoritativeStorage SetAuthoritative storage sets a replica's generation to be the latest one as a way to accept dataloss when all copies of the repository on the latest generation are lost. To replicate the promoted replica to the other storages, the method also schedules replication jobs to other storages. Since the introduction of the automatic reconciler, this is not really necessary as the reconciler would handle the job scheduling. The method also doesn't take into account whether the other storages are assigned hosts of the repository, and instead replicates the repository everywhere. The method should also be expanded to handle repository ID propagation via the replication jobs. To solve both problems at once, this commit removes the explicit job scheduling from SetAuthoritativeStorage and let's it rely on the reconciler to schedule the jobs correctly. Changelog: fixed --- internal/praefect/service/info/server.go | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'internal') diff --git a/internal/praefect/service/info/server.go b/internal/praefect/service/info/server.go index 3e32d9135..802dd9164 100644 --- a/internal/praefect/service/info/server.go +++ b/internal/praefect/service/info/server.go @@ -89,25 +89,5 @@ func (s *Server) SetAuthoritativeStorage(ctx context.Context, req *gitalypb.SetA return nil, helper.ErrInternal(err) } - // Schedule replication jobs to other physical storages to get them consistent with the - // new authoritative repository. - for _, storage := range storages { - if storage == req.AuthoritativeStorage { - continue - } - - if _, err := s.queue.Enqueue(ctx, datastore.ReplicationEvent{ - Job: datastore.ReplicationJob{ - Change: datastore.UpdateRepo, - VirtualStorage: req.VirtualStorage, - RelativePath: req.RelativePath, - SourceNodeStorage: req.AuthoritativeStorage, - TargetNodeStorage: storage, - }, - }); err != nil { - return nil, helper.ErrInternal(err) - } - } - return &gitalypb.SetAuthoritativeStorageResponse{}, nil } -- cgit v1.2.3 From 1fcf22c1049579a1e9d5d4d1fcccfe1e37889028 Mon Sep 17 00:00:00 2001 From: Sami Hiltunen Date: Thu, 19 Aug 2021 17:50:36 +0200 Subject: Do not inject replication queue into InfoService InfoService previously used the replication queue to schedule replication jobs as part of the manual reconciliation command and when accepting data loss. The manual reconciler has been removed and accepting data loss relies on the automatic reconciler. As the InfoService no longer needs to queue replication jobs, this commit removes the unnecessary field and updates the call sites not to inject the queue. --- internal/praefect/server.go | 2 +- internal/praefect/service/info/server.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/praefect/server.go b/internal/praefect/server.go index 017d6742f..4eb4b1c4c 100644 --- a/internal/praefect/server.go +++ b/internal/praefect/server.go @@ -154,7 +154,7 @@ func registerServices( ) { // ServerServiceServer is necessary for the ServerInfo RPC gitalypb.RegisterServerServiceServer(srv, server.NewServer(conf, conns)) - gitalypb.RegisterPraefectInfoServiceServer(srv, info.NewServer(conf, queue, rs, assignmentStore, conns, primaryGetter)) + gitalypb.RegisterPraefectInfoServiceServer(srv, info.NewServer(conf, rs, assignmentStore, conns, primaryGetter)) gitalypb.RegisterRefTransactionServer(srv, transaction.NewServer(tm)) healthpb.RegisterHealthServer(srv, health.NewServer()) diff --git a/internal/praefect/service/info/server.go b/internal/praefect/service/info/server.go index 802dd9164..8ab27ab55 100644 --- a/internal/praefect/service/info/server.go +++ b/internal/praefect/service/info/server.go @@ -37,7 +37,6 @@ type PrimaryGetter interface { type Server struct { gitalypb.UnimplementedPraefectInfoServiceServer conf config.Config - queue datastore.ReplicationEventQueue rs datastore.RepositoryStore assignmentStore AssignmentStore conns service.Connections @@ -47,7 +46,6 @@ type Server struct { // NewServer creates a new instance of a grpc InfoServiceServer func NewServer( conf config.Config, - queue datastore.ReplicationEventQueue, rs datastore.RepositoryStore, assignmentStore AssignmentStore, conns service.Connections, @@ -55,7 +53,6 @@ func NewServer( ) gitalypb.PraefectInfoServiceServer { return &Server{ conf: conf, - queue: queue, rs: rs, assignmentStore: assignmentStore, conns: conns, -- cgit v1.2.3