Skip to content

Commit 0d98c7a

Browse files
craig[bot]michae2
andcommitted
Merge #147869
147869: sql: enable exponential backoff in read committed stmt retry loop r=yuzefovich,stevendanna a=michae2 Increase the defaults of `max_retries_for_read_committed` and `initial_backoff_of_retries_for_read_committed`. See individual commits for details and release notes. Informs: #145377 Release note: None Co-authored-by: Michael Erickson <[email protected]>
2 parents 38afd01 + 7ca7906 commit 0d98c7a

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

pkg/sql/logictest/testdata/logic_test/information_schema

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,7 @@ idle_in_transaction_session_timeout 0
40114011
idle_session_timeout 0
40124012
index_join_streamer_batch_size 8.0 MiB
40134013
index_recommendations_enabled off
4014-
initial_retry_backoff_for_read_committed 0
4014+
initial_retry_backoff_for_read_committed 2
40154015
inject_retry_errors_enabled off
40164016
inject_retry_errors_on_commit_enabled off
40174017
integer_datetimes on
@@ -4036,7 +4036,7 @@ max_connections -1
40364036
max_identifier_length 128
40374037
max_index_keys 32
40384038
max_prepared_transactions 2147483647
4039-
max_retries_for_read_committed 10
4039+
max_retries_for_read_committed 100
40404040
node_id 1
40414041
null_ordered_last off
40424042
on_update_rehome_row_enabled on

pkg/sql/logictest/testdata/logic_test/manual_retry

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ query error restart transaction: TransactionRetryWithProtoRefreshError: forced b
3838
SELECT crdb_internal.force_retry('1h':::INTERVAL)
3939

4040
onlyif config local-read-committed
41-
query error restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
41+
query error restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=100: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
4242
SELECT crdb_internal.force_retry('1h':::INTERVAL)
4343

4444
statement ok

pkg/sql/logictest/testdata/logic_test/pg_catalog

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,7 @@ idle_in_transaction_session_timeout 0 N
30053005
idle_session_timeout 0 NULL NULL NULL string
30063006
index_join_streamer_batch_size 8.0 MiB NULL NULL NULL string
30073007
index_recommendations_enabled off NULL NULL NULL string
3008-
initial_retry_backoff_for_read_committed 0 NULL NULL NULL string
3008+
initial_retry_backoff_for_read_committed 2 NULL NULL NULL string
30093009
inject_retry_errors_enabled off NULL NULL NULL string
30103010
inject_retry_errors_on_commit_enabled off NULL NULL NULL string
30113011
integer_datetimes on NULL NULL NULL string
@@ -3030,7 +3030,7 @@ max_connections -1 N
30303030
max_identifier_length 128 NULL NULL NULL string
30313031
max_index_keys 32 NULL NULL NULL string
30323032
max_prepared_transactions 2147483647 NULL NULL NULL string
3033-
max_retries_for_read_committed 10 NULL NULL NULL string
3033+
max_retries_for_read_committed 100 NULL NULL NULL string
30343034
node_id 1 NULL NULL NULL string
30353035
null_ordered_last off NULL NULL NULL string
30363036
on_update_rehome_row_enabled on NULL NULL NULL string
@@ -3236,7 +3236,7 @@ idle_in_transaction_session_timeout 0 N
32363236
idle_session_timeout 0 NULL user NULL 0s 0s
32373237
index_join_streamer_batch_size 8.0 MiB NULL user NULL 8.0 MiB 8.0 MiB
32383238
index_recommendations_enabled off NULL user NULL on false
3239-
initial_retry_backoff_for_read_committed 0 NULL user NULL 0s 0s
3239+
initial_retry_backoff_for_read_committed 2 NULL user NULL 2ms 2ms
32403240
inject_retry_errors_enabled off NULL user NULL off off
32413241
inject_retry_errors_on_commit_enabled off NULL user NULL off off
32423242
integer_datetimes on NULL user NULL on on
@@ -3261,7 +3261,7 @@ max_connections -1 N
32613261
max_identifier_length 128 NULL user NULL 128 128
32623262
max_index_keys 32 NULL user NULL 32 32
32633263
max_prepared_transactions 2147483647 NULL user NULL 2147483647 2147483647
3264-
max_retries_for_read_committed 10 NULL user NULL 10 10
3264+
max_retries_for_read_committed 100 NULL user NULL 100 100
32653265
node_id 1 NULL user NULL 1 1
32663266
null_ordered_last off NULL user NULL off off
32673267
on_update_rehome_row_enabled on NULL user NULL on on

pkg/sql/logictest/testdata/logic_test/show_source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ idle_in_transaction_session_timeout 0
119119
idle_session_timeout 0
120120
index_join_streamer_batch_size 8.0 MiB
121121
index_recommendations_enabled off
122-
initial_retry_backoff_for_read_committed 0
122+
initial_retry_backoff_for_read_committed 2
123123
inject_retry_errors_enabled off
124124
inject_retry_errors_on_commit_enabled off
125125
integer_datetimes on
@@ -144,7 +144,7 @@ max_connections -1
144144
max_identifier_length 128
145145
max_index_keys 32
146146
max_prepared_transactions 2147483647
147-
max_retries_for_read_committed 10
147+
max_retries_for_read_committed 100
148148
node_id 1
149149
null_ordered_last off
150150
on_update_rehome_row_enabled on

pkg/sql/logictest/testdata/logic_test/txn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ query error pgcode 40001 restart transaction: TransactionRetryWithProtoRefreshEr
11881188
SELECT crdb_internal.force_retry('1h':::INTERVAL)
11891189

11901190
onlyif config local-read-committed
1191-
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
1191+
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=100: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
11921192
SELECT crdb_internal.force_retry('1h':::INTERVAL)
11931193

11941194
query T
@@ -1330,7 +1330,7 @@ query error pgcode 40001 restart transaction: TransactionRetryWithProtoRefreshEr
13301330
SELECT crdb_internal.force_retry('1h':::INTERVAL)
13311331

13321332
onlyif config local-read-committed
1333-
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
1333+
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=100: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
13341334
SELECT crdb_internal.force_retry('1h':::INTERVAL)
13351335

13361336
statement ok
@@ -1602,7 +1602,7 @@ query error pgcode 40001 restart transaction: TransactionRetryWithProtoRefreshEr
16021602
SELECT crdb_internal.force_retry('1h':::INTERVAL)
16031603

16041604
onlyif config local-read-committed
1605-
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
1605+
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=100: TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
16061606
SELECT crdb_internal.force_retry('1h':::INTERVAL)
16071607

16081608
statement ok

pkg/sql/opt/exec/explain/output_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ func TestRetryFields(t *testing.T) {
362362
sqlDB := sqlutils.MakeSQLRunner(conn)
363363
sqlDB.Exec(t, "CREATE SEQUENCE s")
364364
sqlDB.Exec(t, "CREATE TABLE a (a INT)")
365+
// Speed up retries.
366+
sqlDB.Exec(t, "SET initial_retry_backoff_for_read_committed = '1us'")
365367

366368
retryCountRE := regexp.MustCompile(`number of transaction retries: (\d+)`)
367369
retryTimeRE := regexp.MustCompile(`time spent retrying the transaction: ([\d\.]+)[µsm]+`)

pkg/sql/vars.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ var varGen = map[string]sessionVar{
22752275
return strconv.FormatInt(int64(evalCtx.SessionData().MaxRetriesForReadCommitted), 10), nil
22762276
},
22772277
GlobalDefault: func(sv *settings.Values) string {
2278-
return "10"
2278+
return "100"
22792279
},
22802280
},
22812281

@@ -4060,7 +4060,7 @@ var varGen = map[string]sessionVar{
40604060
return strconv.FormatInt(ms, 10), nil
40614061
},
40624062
GlobalDefault: func(sv *settings.Values) string {
4063-
return "0s"
4063+
return "2ms"
40644064
},
40654065
},
40664066
}

0 commit comments

Comments
 (0)