-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: transaction_read_only
can be reset in AOST txns
#44200
Comments
@andreimatei can you have a look at the above. This is a serious issue. |
I think the durable fix is to push the |
cc @cockroachdb/sql-execution |
I've looked superficially and it seems to me that at least the
We seem to be plumbing evalCtx.TxnReadOnly fine as far as I can see. Except obviously something is broken.
I'm reticent to add a read-only mode to I'll pass this over to @jordanlewis to look into. |
What is broken is that the For reference
|
My recommendation above to have a "read only" flag inside @tbg mind chiming in for advice? |
Why? What's wrong with writing after calling |
It's totally wrong enabling KV writes by SQL transactions in an AOST txn. |
The way I see it, if it is wrong, then it should be enforced just like a But I don't necessarily think that it's wrong for AOST transactions to write (although perhaps you should opt into it). If what you want is to write based on data from the past, I think there are use cases for that. The writes will fail, of course, if they're trying to overwrite more recent writes. But if you're writing to a unique row (say |
|
Even if we had an API for read-only txns in place, we would want awareness in SQL to avoid writing in such transactions (clearly broken right now). My personal preference would be to focus on fixing that. After that point, any kind of check we add to in |
I think I now want both levels of checks. I'll look into it. |
The clean API would be one that separates the concerns - fixing of the timestamp vs protection against programming errors by refusing some operations. It's one thing to not particularly try to support features around "writing in the past", but it's another thing to disallow them by fiat. My worry with starting to teach KV about read-only txns is that there's a logical level and there's a physical level and both could in theory be desired, and I'm afraid of trying to decide which is which. Should a read-only txn push other txns? Should a read-only transaction clean up intents from other transactions? Should it cause range leases to be acquired? Should it causes liveness records to have their epochs bumped? |
I'll grant you that.
I think all these are valid questions but somewhat orthogonal. Once we have introduced the notion of read-only txns, we can decide (later) whether/how we can optimize them further. |
A side note on the For us a value coming from the connection string, through |
We have marked this issue as stale because it has been inactive for |
120097: sql: mark implicit transactions with AOST as read-only r=yuzefovich,rafiss a=michae2 **sql: mark implicit transactions with AOST as read-only** In `handleAOST` we were setting the transaction AOST but not marking it as read-only. It needs to also be marked as read-only to disallow mutation statements and locking statements. Fixes: #120081 Release note (sql change): Mutation statements such as UPDATE and DELETE as well as locking statements such as SELECT FOR UPDATE are not allowed in read-only transactions or AS OF SYSTEM TIME transactions. Fix an oversight where we were allowing mutation statements and locking statements in implicit single-statement transactions using AS OF SYSTEM TIME. --- **sql: disallow SET transaction_read_only = false during AOST txn** Fixes: #44200 Release note (bug fix): Fix a bug in which it was possible to `SET transaction_read_only = false` during an AS OF SYSTEM TIME transaction. 120147: catalog: add maybeAddConstraintIDs to RestoreChanges r=rafiss a=rafiss This partially reverts 8b56efd All backups taken in versions 22.1 and later should already have constraint IDs set. Technically, now that we are in v24.1, we no longer support restoring from versions older than 22.1, but we still have tests that restore from old versions. Until those fixtures are updated, we need to handle the case where constraint IDs are not set already when restoring a backup. To prove that this works, I've resurrected a different test that restores from a v21.1 backup, which was earlier deleted in 8b56efd. informs #120146 Release note: None 120148: tests: move some tests to `heavy` pools in `race`, `deadlock` r=rail a=rickystewart Epic: CRDB-8308 Release note: None Co-authored-by: Michael Erickson <[email protected]> Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
Fixes: cockroachdb#44200 Release note (bug fix): Fix a bug in which it was possible to `SET transaction_read_only = false` during an AS OF SYSTEM TIME transaction.
Fixes: cockroachdb#44200 Release note (bug fix): Fix a bug in which it was possible to `SET transaction_read_only = false` during an AS OF SYSTEM TIME transaction.
The following works and should not:
This succeeds and lets the transaction do stuff with the table !!?!?!
It also leaves over junk data in ranges. I haven't checked but I suspect it also leaves junk data at historical timestamps which will confuse the GC (and possibly let node crashes when table readers get their table data removed from "under them" asynchronously by a confused GC.
I am expecting an error on the SET: "cannot set a txn read/write when operating at a past timestamp"
Found while investigating #44188 (comment)
Jira issue: CRDB-5245
The text was updated successfully, but these errors were encountered: