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: prevent illegal concurrency with internal executor in some cases #119176
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @rafiss)
Previously, it was possible for some methods of the internal executor result in illegal concurrency. In particular, `QueryIterator{Ex}` methods allow for the result of the internal query to be consumed in "streaming" fashion but we must do so without any concurrency, and it's achieved by using "sync" result channel (which synchronizes the reader ("outer" query) and the writer (InternalExecutor)). However, previously the internal query could result in illegal concurrency on its own - if it happens to use DistSQL. During 23.1 time frame we started populating the SessionData with proper session defaults in some cases and completed this work in 23.2; as a result, the internally-executed queries can now use DistSQL, but we must disable it in this "sync" mode, when the root txn is specified, which is what this commit does. We already made a similar change to disable the Streamer some time ago for the same reason in ed3f640. I spent quite a few hours to come up with a reproduction but didn't succeed, so there is no regression test in this commit. Release note (bug fix): Previously, CockroachDB could encounter an internal error "attempting to append refresh spans after the tracked timestamp has moved forward" in some cases when using virtual tables (like `crdb_internal.system_jobs`, etc), and this has now been fixed. The bug was introduced in 23.1 version.
This commit makes it so that the streamer is disabled in the internal executor in exactly the same scenario when DistSQL was disabled in the previous commit. This change polishes the fix in ed3f640 to be more precise. It's in a separate commit since it won't be backported (unlike the previous one). Release note: None
TFTR! bors r+ |
Build succeeded: |
Previously, it was possible for some methods of the internal executor result in illegal concurrency. In particular,
QueryIterator{Ex}
methods allow for the result of the internal query to be consumed in "streaming" fashion but we must do so without any concurrency, and it's achieved by using "sync" result channel (which synchronizes the reader ("outer" query) and the writer (InternalExecutor)). However, previously the internal query could result in illegal concurrency on its own - if it happens to use DistSQL. During 23.1 time frame we started populating the SessionData with proper session defaults in some cases and completed this work in 23.2; as a result, the internally-executed queries can now use DistSQL, but we must disable it in this "sync" mode, when the root txn is specified, which is what this commit does.We already made a similar change to disable the Streamer some time ago for the same reason in ed3f640.
I spent quite a few hours to come up with a reproduction but didn't succeed, so there is no regression test in this commit.
Fixes: #118542.
Release note (bug fix): Previously, CockroachDB could encounter an internal error "attempting to append refresh spans after the tracked timestamp has moved forward" in some cases when using virtual tables (like
crdb_internal.system_jobs
, etc), and this has now been fixed. The bug was introduced in 23.1 version.