Skip to content

Commit 5d697b9

Browse files
committed
FIX TestTxnContentionEventsTable by forcing CPuts on non-unique secondary
1 parent 01c935a commit 5d697b9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: pkg/sql/crdb_internal_test.go

+13
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

0 commit comments

Comments
 (0)