-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: disable stats injection within an explicit transaction #46567
Conversation
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.
I don't think this works. There are two problems:
- the table stats cache is not scoped per txn; with this change, if the txn that injected stats gets aborted, the new stats will still stay in the cache and will be accessible. They are actually accessible to other queries even before the transaction commits or aborts.
- We want the stats cache to use a separate transaction which can be auto-retried on its own. We don't want a user transaction to get aborted because the table stats hit a conflict (because a table stat was recently refreshed).
I think we should just not support injecting statistics inside a transaction (or do the injection insert using a separate transaction so that it's not tied to the outer transaction).
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @rytaft)
I see, I didn't consider those effects. That makes sense.
I'll play around with these ideas. |
61cdfc6
to
e101d21
Compare
PTAL Running the injection in a separate transaction leads to the same deadlock it seems. So I went ahead and disabled stats injection in explicit transactions. |
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.
Great, thanks for the fix!
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @rohany and @rytaft)
pkg/sql/logictest/testdata/logic_test/alter_table, line 1120 at r1 (raw file):
statement error pq: cannot inject statistics in an explicit transaction ALTER TABLE inject_stats INJECT STATISTICS '[ {
[nit] this can probably just be []
. We definitely don't need these crazy counts :)
Fixes cockroachdb#42421. Release justification: Disables a situation that could lead to a deadlock. Release note (sql change): Disables to ability to inject stats within an explicit transaction.
e101d21
to
3dc2bc0
Compare
lol true :D bors r+ |
Build failed (retrying...) |
Build succeeded |
Fixes #42421.
Release justification: Disables a situation that could lead to a
deadlock.
Release note (sql change): Disables to ability to inject stats
within an explicit transaction.