Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-07-15 14:48:45 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-07-16 10:55:18 +0300
commit31a0f591e965d3b2d52fe139f7e7d30d7474f504 (patch)
tree611f8564253dced54e0d2c9533873162916934a4
parent48d188f34ce855d85c01b1f0a555c9354d912014 (diff)
transactions: Merge vote and collection functions
The only reason why the transaction's `vote` and `collectVotes` functions is split into two parts is because of locking complexities. Now that locking has been moved into subtransactions, let's merge both functions to avoid any potential misuse of the interface.
-rw-r--r--internal/praefect/transactions/manager.go6
-rw-r--r--internal/praefect/transactions/transaction.go9
2 files changed, 5 insertions, 10 deletions
diff --git a/internal/praefect/transactions/manager.go b/internal/praefect/transactions/manager.go
index 0cb967209..252146dda 100644
--- a/internal/praefect/transactions/manager.go
+++ b/internal/praefect/transactions/manager.go
@@ -158,11 +158,7 @@ func (mgr *Manager) voteTransaction(ctx context.Context, transactionID uint64, n
return ErrNotFound
}
- if err := transaction.vote(node, hash); err != nil {
- return err
- }
-
- if err := transaction.collectVotes(ctx, node); err != nil {
+ if err := transaction.vote(ctx, node, hash); err != nil {
return err
}
diff --git a/internal/praefect/transactions/transaction.go b/internal/praefect/transactions/transaction.go
index c994264a7..33584fda9 100644
--- a/internal/praefect/transactions/transaction.go
+++ b/internal/praefect/transactions/transaction.go
@@ -78,10 +78,9 @@ func (t *transaction) cancel() map[string]bool {
return t.subtransaction.cancel()
}
-func (t *transaction) vote(node string, hash []byte) error {
- return t.subtransaction.vote(node, hash)
-}
-
-func (t *transaction) collectVotes(ctx context.Context, node string) error {
+func (t *transaction) vote(ctx context.Context, node string, hash []byte) error {
+ if err := t.subtransaction.vote(node, hash); err != nil {
+ return err
+ }
return t.subtransaction.collectVotes(ctx, node)
}