cockroachdb / cockroachdb/cockroach
kvcoord: reconsider how the TxnCoordSender determines `hasPerformedWrites`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
References https://github.com/cockroachdb/cockroach/pull/93175#issuecomment-1342901449
`TxnCoordSender.hasPerformedWrites` is primarily used to determine if we can run a transaction at a fixed timestamp (for example, for AOST queries). The idea being we can only do this if no writes have been performed in current Epoch.
We currently make this determination by checking the `Sequence` on the transaction. As the comment linked above points out, this isn't great for a couple of reasons -- for one, it relies on command evaluation to modify the transaction's sequence number (to a write request's sequence number, which is non-zero) when performing writes. It also doesn't work if the `TxnCoordSender` doesn't receive a message from a write request.
However, making the suggested change from the comment doesn't quite work -- this is because `lockFootprint` tracks locks for all epochs, not just the current epoch. Maybe we could separately track locks from previous epochs in a `condensableSpanSet`? cc @nvanbenschoten
Alternatively, how much would we care if we changed the behaviour such that locks acquired at old epochs prevented us from setting a fixed timestamp for a transaction?
Jira issue: CRDB-22506
Contributor guide
Assessment
This issue has not been assessed yet.