Skip to content

Commit

Permalink
logic: skip_on_retry works when errors are expected
Browse files Browse the repository at this point in the history
Previously, we have `skip_on_retry` directive for logic test which, when
set, it skips the rest of test if a statement fails with
TransactionRetryError. However, it won't skip if the statement is
expected to fail with certain error message. This PR ensures that
whenever we have a TransactionRetryError and `skip_on_retry` is set, we
always skip the rest of the test, even if the stmt is expected to fail.

Informs cockroachdb#104464

Release note: None
  • Loading branch information
Xiang-Gu committed Jul 13, 2023
1 parent b19302f commit 00d78c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/schema_change_in_txn
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Skip the rest of the test if a retry occurs. They can happen and are fine
# but there's no way to encapsulate that in logictests.
skip_on_retry

# Backing up and restoring a descriptor will increment the version of the
# descriptor before restoring it so we cannot achieve the expected behaviour in
# this test.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3130,8 +3130,8 @@ func (t *logicTest) maybeSkipOnRetry(err error) {
func (t *logicTest) verifyError(
sql, pos, expectNotice, expectErr, expectErrCode string, err error,
) (bool, error) {
t.maybeSkipOnRetry(err)
if expectErr == "" && expectErrCode == "" && err != nil {
t.maybeSkipOnRetry(err)
return t.unexpectedError(sql, pos, err)
}
if expectNotice != "" {
Expand Down

0 comments on commit 00d78c7

Please sign in to comment.