Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/logictest: fix flakes in select_for_update_read_committed #112701

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Oct 19, 2023

The select_for_update_read_committed tests were flaking because not
all statements were being run under READ COMMITTED isolation. The logic
test infrastructure does not allow fine-grained control of sessions, and
setting the isolation level in one statement would only apply to a
single session. Subsequent statements are not guaranteed to run in the
same session because they could run in any session in the connection
pool. This commit wraps each statement in an explicitly transaction with
an explicit isolation level to ensure READ COMMITTED is used.

In the future, we should investigate allowing fine-grained and explicit
control of sessions in logic tests.

Fixes #112677

Release note: None

@mgartner mgartner requested review from a team and michae2 and removed request for a team October 19, 2023 17:00
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner mgartner force-pushed the 112677-fix-read-committed-flakes branch from 9c63f1d to 781841d Compare October 19, 2023 17:00
@mgartner mgartner added the backport-23.2.x Flags PRs that need to be backported to 23.2. label Oct 19, 2023
@mgartner mgartner requested review from a team October 19, 2023 17:09
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Thank you!!

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)


pkg/sql/logictest/testdata/logic_test/select_for_update_read_committed line 81 at r1 (raw file):

COMMIT;
----
20  200  2000

I think what's happening here is that SKIP LOCKED doesn't quite work with shared locks yet: #110743

Maybe we could bring the (incorrect) 3-row result back, with a note about that issue?

@mgartner
Copy link
Collaborator Author

pkg/sql/logictest/testdata/logic_test/select_for_update_read_committed line 81 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

I think what's happening here is that SKIP LOCKED doesn't quite work with shared locks yet: #110743

Maybe we could bring the (incorrect) 3-row result back, with a note about that issue?

I can't get this failure to reproduce locally, and if I add the three rows back the tests fails locally.

@mgartner mgartner force-pushed the 112677-fix-read-committed-flakes branch from 781841d to 46c4355 Compare October 19, 2023 17:42
@mgartner
Copy link
Collaborator Author

pkg/sql/logictest/testdata/logic_test/select_for_update_read_committed line 81 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

I can't get this failure to reproduce locally, and if I add the three rows back the tests fails locally.

Nevermind, I think I found the problem—I forgot to include the change to set the txn isolation of the first BEGIN.

The `select_for_update_read_committed` tests were flaking because not
all statements were being run under READ COMMITTED isolation. The logic
test infrastructure does not allow fine-grained control of sessions, and
setting the isolation level in one statement would only apply to a
single session. Subsequent statements are not guaranteed to run in the
same session because they could run in any session in the connection
pool. This commit wraps each statement in an explicitly transaction with
an explicit isolation level to ensure READ COMMITTED is used.

In the future, we should investigate allowing fine-grained and explicit
control of sessions in logic tests.

Fixes cockroachdb#112677

Release note: None
@mgartner mgartner force-pushed the 112677-fix-read-committed-flakes branch from 46c4355 to 430cffc Compare October 20, 2023 15:05
@mgartner
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Oct 20, 2023

Build succeeded:

@craig craig bot merged commit 48baa96 into cockroachdb:master Oct 20, 2023
3 checks passed
@mgartner mgartner deleted the 112677-fix-read-committed-flakes branch October 20, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg/sql/logictest/tests/local/local_test: TestLogic_select_for_update_read_committed failed
3 participants