diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-10 17:59:06 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-13 09:47:19 +0300 |
commit | cfd0fd048b46f4d783880f0774ffbdb7abcc8cb4 (patch) | |
tree | e06302d78fc93f3065e50fbc2e7c4a1f34004089 /internal/gitaly/service/repository/apply_gitattributes.go | |
parent | 0c08541cf496d76c5611ee1e7bcfc49724dbcc21 (diff) |
transaction: Wire up transactional voting phases
Convert all callsites which perform transactional voting to specify the
phase the vote is being cast in. This information is not yet used by
Praefect yet, but serves as the baseline to make more informed
replication decisions in Praefect's at some point.
Ideally, all sites would either use "prepared" or "committed" as their
phase. But we have some callsites which don't use proper two-phase
voting, which thus cast their votes with "unknown" phase. These will
need to get converted eventually.
Diffstat (limited to 'internal/gitaly/service/repository/apply_gitattributes.go')
-rw-r--r-- | internal/gitaly/service/repository/apply_gitattributes.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/gitaly/service/repository/apply_gitattributes.go b/internal/gitaly/service/repository/apply_gitattributes.go index 82a08d1a1..8f188183a 100644 --- a/internal/gitaly/service/repository/apply_gitattributes.go +++ b/internal/gitaly/service/repository/apply_gitattributes.go @@ -66,7 +66,7 @@ func (s *server) applyGitattributes(ctx context.Context, repo *localrepo.Repo, o // We use the zero OID as placeholder to vote on removal of the // gitattributes file. - if err := s.vote(ctx, git.ZeroOID); err != nil { + if err := s.vote(ctx, git.ZeroOID, voting.Prepared); err != nil { return fmt.Errorf("preimage vote: %w", err) } @@ -74,7 +74,7 @@ func (s *server) applyGitattributes(ctx context.Context, repo *localrepo.Repo, o return err } - if err := s.vote(ctx, git.ZeroOID); err != nil { + if err := s.vote(ctx, git.ZeroOID, voting.Committed); err != nil { return fmt.Errorf("postimage vote: %w", err) } @@ -83,7 +83,7 @@ func (s *server) applyGitattributes(ctx context.Context, repo *localrepo.Repo, o // If there is no gitattributes file, we simply use the ZeroOID // as a placeholder to vote on the removal. - if err := s.vote(ctx, git.ZeroOID); err != nil { + if err := s.vote(ctx, git.ZeroOID, voting.UnknownPhase); err != nil { return fmt.Errorf("could not remove gitattributes: %w", err) } @@ -114,7 +114,7 @@ func (s *server) applyGitattributes(ctx context.Context, repo *localrepo.Repo, o return nil } -func (s *server) vote(ctx context.Context, oid git.ObjectID) error { +func (s *server) vote(ctx context.Context, oid git.ObjectID, phase voting.Phase) error { tx, err := txinfo.TransactionFromContext(ctx) if errors.Is(err, txinfo.ErrTransactionNotFound) { return nil @@ -130,7 +130,7 @@ func (s *server) vote(ctx context.Context, oid git.ObjectID) error { return fmt.Errorf("cannot convert OID to vote: %w", err) } - if err := s.txManager.Vote(ctx, tx, vote); err != nil { + if err := s.txManager.Vote(ctx, tx, vote, phase); err != nil { return fmt.Errorf("vote failed: %w", err) } |