Skip to content

Commit bfa08c7

Browse files
committed
human readable attempts in logs
1 parent 836b76f commit bfa08c7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

internal/table/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ func (c *Client) internalPoolGet(ctx context.Context, opts ...getOption) (s *ses
352352
}()
353353

354354
const maxAttempts = 100
355-
for ; s == nil && err == nil && i < maxAttempts && !c.isClosed(); i++ {
355+
for s == nil && err == nil && i < maxAttempts && !c.isClosed() {
356+
i++
356357
// First, we try to internalPoolGet session from idle
357358
c.mu.WithLock(func() {
358359
s = c.internalPoolRemoveFirstIdle()

internal/table/retry.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ func doTx(
4444
opts.SlowBackoff,
4545
opts.Idempotent,
4646
func(ctx context.Context, s table.Session) (err error) {
47+
attempts++
48+
4749
defer func() {
4850
onIntermediate(err)
49-
attempts++
5051
}()
5152

5253
tx, err := s.BeginTransaction(ctx, opts.TxSettings)
@@ -111,9 +112,10 @@ func do(
111112
opts.SlowBackoff,
112113
opts.Idempotent,
113114
func(ctx context.Context, s table.Session) (err error) {
115+
attempts++
116+
114117
defer func() {
115118
onIntermediate(err)
116-
attempts++
117119
}()
118120

119121
err = func() error {

0 commit comments

Comments
 (0)