Skip to content

Commit 4c40f45

Browse files
craig[bot]miraradeva
andcommitted
157758: Revert "kv: add a backoff to the retry loop in db.Txn" r=stevendanna a=miraradeva This reverts commit ef5deaa. Since this commit was introduced, we've addressed the underlying backoff issue within kvnemesis (cockroachdb#137092). We don't need the backoff for all users of the `db.Txn` API; in fact, a 20ms backoff might be too aggressive for most non-kvnemesis use cases. Informs: cockroachdb#136266 Release note: None Co-authored-by: Mira Radeva <[email protected]>
2 parents 72e5734 + 7916e79 commit 4c40f45

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

pkg/kv/txn.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"math"
1212
"time"
1313

14-
"github.com/cockroachdb/cockroach/pkg/base"
1514
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
1615
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts"
1716
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts/ctpb"
@@ -26,7 +25,6 @@ import (
2625
"github.com/cockroachdb/cockroach/pkg/util/interval"
2726
"github.com/cockroachdb/cockroach/pkg/util/log"
2827
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
29-
"github.com/cockroachdb/cockroach/pkg/util/retry"
3028
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
3129
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
3230
"github.com/cockroachdb/cockroach/pkg/util/uuid"
@@ -1134,10 +1132,7 @@ func (e *AutoCommitError) Error() string {
11341132
func (txn *Txn) exec(ctx context.Context, fn func(context.Context, *Txn) error) (err error) {
11351133
// Run fn in a retry loop until we encounter a success or
11361134
// error condition this loop isn't capable of handling.
1137-
retryOpts := base.DefaultRetryOptions()
1138-
retryOpts.InitialBackoff = 20 * time.Millisecond
1139-
retryOpts.MaxBackoff = 200 * time.Millisecond
1140-
for r := retry.Start(retryOpts); r.Next(); {
1135+
for attempt := 1; ; attempt++ {
11411136
if err := ctx.Err(); err != nil {
11421137
return errors.Wrap(err, "txn exec")
11431138
}
@@ -1203,8 +1198,6 @@ func (txn *Txn) exec(ctx context.Context, fn func(context.Context, *Txn) error)
12031198
// cluster setting to be changed while a transaction is stuck in a retry
12041199
// loop.
12051200
maxRetries := txn.MaxAutoRetries()
1206-
// Add 1 because r.CurrentAttempt() starts at 0.
1207-
attempt := r.CurrentAttempt() + 1
12081201
if attempt > maxRetries {
12091202
// If the retries limit has been exceeded, rollback and return an error.
12101203
rollbackErr := txn.Rollback(ctx)

0 commit comments

Comments
 (0)