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:
authorJames Fargher <proglottis@gmail.com>2020-08-13 05:28:20 +0300
committerJames Fargher <proglottis@gmail.com>2020-08-13 05:28:20 +0300
commit83b5e30a98b1af89071672a90a7a63a575cbfc03 (patch)
tree2a356ca88dd4584d223c08643f556fc0f4768330
parentb99503ecad99b68282517015ab0f2e91378ddd88 (diff)
parent2894e8325f3f24f2cbaad1cab4393c26228dc7bd (diff)
Merge branch 'pks-tx-log-finished' into 'master'
Log transaction state when cancelling them See merge request gitlab-org/gitaly!2465
-rw-r--r--changelogs/unreleased/pks-tx-log-finished.yml5
-rw-r--r--internal/praefect/transactions/manager.go19
2 files changed, 22 insertions, 2 deletions
diff --git a/changelogs/unreleased/pks-tx-log-finished.yml b/changelogs/unreleased/pks-tx-log-finished.yml
new file mode 100644
index 000000000..93f8d4bbf
--- /dev/null
+++ b/changelogs/unreleased/pks-tx-log-finished.yml
@@ -0,0 +1,5 @@
+---
+title: Log transaction state when cancelling them
+merge_request: 2465
+author:
+type: added
diff --git a/internal/praefect/transactions/manager.go b/internal/praefect/transactions/manager.go
index 1afc03588..c3527db16 100644
--- a/internal/praefect/transactions/manager.go
+++ b/internal/praefect/transactions/manager.go
@@ -6,6 +6,7 @@ import (
"encoding/binary"
"encoding/hex"
"errors"
+ "fmt"
"math/rand"
"sync"
"time"
@@ -146,11 +147,11 @@ func (mgr *Manager) RegisterTransaction(ctx context.Context, voters []Voter, thr
mgr.counterMetric.WithLabelValues("registered").Add(float64(len(voters)))
return transaction, func() error {
- return mgr.cancelTransaction(transaction)
+ return mgr.cancelTransaction(ctx, transaction)
}, nil
}
-func (mgr *Manager) cancelTransaction(transaction *Transaction) error {
+func (mgr *Manager) cancelTransaction(ctx context.Context, transaction *Transaction) error {
mgr.lock.Lock()
defer mgr.lock.Unlock()
@@ -159,6 +160,20 @@ func (mgr *Manager) cancelTransaction(transaction *Transaction) error {
transaction.cancel()
mgr.subtransactionsMetric.Observe(float64(transaction.CountSubtransactions()))
+ var committed uint64
+ state := transaction.State()
+ for _, success := range state {
+ if success {
+ committed++
+ }
+ }
+
+ mgr.log(ctx).WithFields(logrus.Fields{
+ "transaction_id": transaction.ID(),
+ "committed": fmt.Sprintf("%d/%d", committed, len(state)),
+ "subtransactions": transaction.CountSubtransactions(),
+ }).Info("transaction completed")
+
return nil
}