-
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
kv: child transactions #54633
Comments
Hi @ajwerner, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Will we ever want to run DistSQL flows for child transactions? Everything else here lines up with my expectations except for the extension to the
To confirm, the |
Ack on the
Fair, it just felt right, I don't have strong feelings. I'll just remove that whole thing
Correct, that's the idea. I'll make it more explicit. |
@nvanbenschoten added some more commentary on a problem I'm seeing to remove the |
Yeah, this seems tricky. I don't see a great way that we can coalesce all lease acquisitions using child transactions without introducing some form of multiple inheritance, which we should try to avoid at all costs. Do we need to coalesce lease acquisition in all cases? Can we determine when the transaction inheritance is needed to avoid deadlocks and avoid coalescing in those cases, using a child transaction instead? One thing that's not clear to me is whether the child transactions need to be able to read the provisional values of the parent transactions in this case, or whether they should just be able to push them. Are there two different use cases here? Can we get away with only supporting one or the other? |
It's not obvious to me how to do that. In general I think this issue is thorny. One solution would be to continue to use
Yeah, totally agree. Reading the provisional values is really needed for the transactional schema changes. For the leasing it's not even desirable. I was thinking that supporting it but being able to set the sequence number was a generalization. |
It turns out that making distributed deadlock detection work correctly with child transactions is a little more involved than I thought it was going to be. It looks like we're going to need to have a child transaction watch all of its ancestor's records as well as its own when in the Here's an example that demonstrates why we need both of these changes:
Interestingly, this means that we do not need to persist a transaction's ancestor list inside its intents, so I don't even think it needs to live inside of |
Thanks for thinking through this! |
We have marked this issue as stale because it has been inactive for |
Is your feature request related to a problem? Please describe.
KV transactions provide serializable isolation for a series of KV operations. Importantly, the KV layer also provides deadlock detection to ensure that the system remains live. This deadlock detection system makes an assumption that each operation transaction corresponds to a single thread of execution which dependent on the liveness of another transaction to make progress. We've observed a variety of deadlocks related to descriptor lease acquisition and query planning which invalidated that assumption (#24885, #46224, #46447). The solutions (#46170, #46384, #46588) to these deadlocks was to run the "child" operation at
PRIORITY HIGH
in hopes that the intent on which the operations blocked were not run at that priority. Unfortunately this was really just a band-aid and if users did run their schema change operations atPRIORITY HIGH
we'd still have those deadlocks.Another related problem with the current transactional model is that it does not provide a mechanism to run a secondary transaction on the thread of execution of another transaction which might encounter intents (of the parent transaction or of another transaction which might be blocked on the parents). This is a critical component of the proposed scheme for providing transactional schema changes. It is important to enable changes to the database for the purpose of coordinating with concurrent transactions but allowing the parent to avoid interacting with changing keys in order to retain its serializable view of the database.
Describe the solution you'd like
The proposal is that we create a new type of transaction, a
child
transaction to join the existing two types of transactions,root
transactions andleaf
transactions. A child transaction is an independent read-write transaction that refers to a parent transaction at a given sequence and snapshot. For the purpose of deadlock detection, the parent will be seen as being blocked on the child (more details below). The child transaction will read written values of the parent as though it were the parent transaction.Implementation details
The child transaction will have a new field in its
enginepb.TxnMeta
. Child transactions may create their own child transactions. In that case, theTxnMeta.Parent.Parent
will be not nil. This will effectively form a linked-list of parents. We do not intend for the depth to get very deep.When the MVCC code encounters an intent it will check if it refers to a parent (recursively).
Deadlock breaking during lease acquisition
A goal of this work should be to cleanup the hacks introduced in #46170 and #46384 which use priority high to push a deadlock caused by lease acquisition blocking on an earlier epoch or rolled back sequence number. Unfortunately, this isn't that simple! The problem is that today we use a single-flight group to coalesce lease acquisition. We have no way to represent the dependency on that singleflight in our distributed deadlock detection.
Jira issue: CRDB-3733
The text was updated successfully, but these errors were encountered: