Skip to content

Commit b5e5b88

Browse files
craig[bot]yuzefovich
andcommitted
Merge #144208
144208: sql: adjust some tests to work with write buffering r=yuzefovich a=yuzefovich This commit adjusts the following tests so that they work with write buffering enabled by default: - `as_of` logic test verifies a particular error message about "already performed writes" on an INSERT whereas with write buffering we get "already performed reads". It doesn't seem like a big deal, so we'll accept the deviation, and this commit makes it explicit. - `TestRetriableErrorDuringUpgradedTransaction` and `TestAbortCountConflictingWrites` use the server filter testing knob which engages _after_ the interceptor stack, so we need to allow for the write to make it there and disable buffering. - in `TestTxnContentionEventsTable` we expect the contention on non-unique secondary index, and since we changed the CPut to a Put there by default, we now tweak the session variable to use CPuts still. Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents 874ad8f + 58e686b commit b5e5b88

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

pkg/sql/conn_executor_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ func TestRetriableErrorDuringUpgradedTransaction(t *testing.T) {
899899

900900
var fooTableId uint32
901901
testDB.Exec(t, "SET enable_implicit_transaction_for_batch_statements = true")
902+
// The test injects a retry error after the interceptors, so we need to
903+
// disable write buffers for the request to make it to the server.
904+
testDB.Exec(t, "SET kv_transaction_buffered_writes_enabled = false")
902905
testDB.Exec(t, "CREATE TABLE bar (a INT PRIMARY KEY)")
903906
testDB.Exec(t, "CREATE TABLE foo (a INT PRIMARY KEY)")
904907
testDB.QueryRow(t, "SELECT 'foo'::regclass::oid").Scan(&fooTableId)

pkg/sql/crdb_internal_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,19 @@ func TestTxnContentionEventsTableMultiTenant(t *testing.T) {
931931
func causeContention(
932932
t *testing.T, conn *gosql.DB, table string, insertValue string, updateValue string,
933933
) {
934+
// Given the schema of the table we expect to experience the contention on
935+
// the non-unique secondary index. By default, with write buffering we no
936+
// longer acquire the lock on those, so we need to tweak the session
937+
// variable.
938+
if _, err := conn.Exec("SET use_cputs_on_non_unique_indexes = true"); err != nil {
939+
t.Fatal(err)
940+
}
941+
defer func() {
942+
if _, err := conn.Exec("RESET use_cputs_on_non_unique_indexes"); err != nil {
943+
t.Fatal(err)
944+
}
945+
}()
946+
934947
// Create a new connection, and then in a go routine have it start a
935948
// transaction, update a row, sleep for a time, and then complete the
936949
// transaction. With original connection attempt to update the same row

pkg/sql/logictest/testdata/logic_test/as_of

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ SET TRANSACTION AS OF system time '-1s'
133133
statement ok
134134
ROLLBACK
135135

136+
skipif config local-mixed-24.3 local-mixed-25.1
137+
statement ok
138+
SET kv_transaction_buffered_writes_enabled = false;
139+
136140
statement ok
137141
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE
138142

@@ -145,6 +149,27 @@ SET TRANSACTION AS OF system time '-1s'
145149
statement ok
146150
ROLLBACK
147151

152+
skipif config local-mixed-24.3 local-mixed-25.1
153+
statement ok
154+
SET kv_transaction_buffered_writes_enabled = true;
155+
156+
statement ok
157+
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE
158+
159+
statement ok
160+
INSERT INTO t VALUES(1)
161+
162+
skipif config local-mixed-24.3 local-mixed-25.1
163+
statement error cannot set fixed timestamp, .* already performed reads
164+
SET TRANSACTION AS OF system time '-1s'
165+
166+
statement ok
167+
ROLLBACK
168+
169+
skipif config local-mixed-24.3 local-mixed-25.1
170+
statement ok
171+
RESET kv_transaction_buffered_writes_enabled;
172+
148173
# Verify that an expression that requires normalization does not result in an
149174
# internal error.
150175
statement error pq: AS OF SYSTEM TIME: expected timestamp, decimal, or interval, got bool

pkg/sql/metric_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ func TestAbortCountConflictingWrites(t *testing.T) {
216216

217217
accum := initializeQueryCounter(s)
218218

219+
// The test injects a retry error after the interceptors, so we need to
220+
// disable write buffers for the request to make it to the server.
221+
if _, err := sqlDB.Exec("SET kv_transaction_buffered_writes_enabled = false"); err != nil {
222+
t.Fatal(err)
223+
}
224+
219225
if _, err := sqlDB.Exec("CREATE DATABASE db"); err != nil {
220226
t.Fatal(err)
221227
}

0 commit comments

Comments
 (0)