diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-02-01 12:10:11 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-02-01 12:11:53 +0300 |
commit | f68eae9ae6f73f96bcefb065cefc763143ec193c (patch) | |
tree | 2aec347b989c729d05a9f9d210470c8b64a09930 /internal/praefect/transactions | |
parent | 88fc02519e91504274d5745b24182e34a3a2c780 (diff) |
transactions: Report voting hash on failed vote
When voting on a transaction fails because quorum wasn't reached, then
we print an error message detailing how many votes we got on the node's
vote. We're still up to a guessing game though which node has agreed or
disagreed on what exact vote, as there is no information about what the
node voted on.
Fix this by including the hash the node voted on in the error message.
Diffstat (limited to 'internal/praefect/transactions')
-rw-r--r-- | internal/praefect/transactions/subtransaction.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/praefect/transactions/subtransaction.go b/internal/praefect/transactions/subtransaction.go index fab1355a5..355ac99fe 100644 --- a/internal/praefect/transactions/subtransaction.go +++ b/internal/praefect/transactions/subtransaction.go @@ -3,6 +3,7 @@ package transactions import ( "context" "crypto/sha1" + "encoding/hex" "fmt" "sync" ) @@ -42,6 +43,11 @@ func (v vote) isEmpty() bool { return v == vote{} } +// String returns the hexadecimal string representation of the vote. +func (v vote) String() string { + return hex.EncodeToString(v[:]) +} + // subtransaction is a single session where voters are voting for a certain outcome. type subtransaction struct { doneCh chan interface{} @@ -222,7 +228,8 @@ func (t *subtransaction) collectVotes(ctx context.Context, node string) error { // shouldn't accept any additional votes. if t.voteCounts[voter.vote] < t.threshold { voter.result = VoteFailed - return fmt.Errorf("%w: got %d/%d votes", ErrTransactionFailed, t.voteCounts[voter.vote], t.threshold) + return fmt.Errorf("%w: got %d/%d votes for %v", ErrTransactionFailed, + t.voteCounts[voter.vote], t.threshold, voter.vote) } voter.result = VoteCommitted |