Skip to content

Commit

Permalink
tries -> attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini committed May 16, 2024
1 parent 0a39298 commit b959393
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/backend/pgbk/atomicwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ func (b *Backend) AtomicWrite(ctx context.Context, condacts []backend.Conditiona
return trace.Wrap(row.Scan(&success))
}

var tries int
var attempts int
err = pgcommon.RetryTx(ctx, b.log, b.pool, pgx.TxOptions{}, false, func(tx pgx.Tx) error {
tries++
attempts++

var condBatch, actBatch pgx.Batch
for _, bi := range condBatchItems {
Expand All @@ -130,14 +130,14 @@ func (b *Backend) AtomicWrite(ctx context.Context, condacts []backend.Conditiona
return nil
})

if tries > 1 {
backend.AtomicWriteContention.WithLabelValues(b.GetName()).Add(float64(tries - 1))
if attempts > 1 {
backend.AtomicWriteContention.WithLabelValues(b.GetName()).Add(float64(attempts - 1))
}

if tries > 2 {
if attempts > 2 {
b.log.WarnContext(ctx,
"AtomicWrite was retried several times due to transaction contention. Some conflict is expected, but persistent conflict warnings may indicate an unhealthy state.",
"tries", tries,
"attempts", attempts,
)
}

Expand Down

0 comments on commit b959393

Please sign in to comment.