concurrency: unreplicated locks don't provide isolation through commit time #142978
Labels
A-buffered-writes
Related to the introduction of buffered writes
A-kv-transactions
Relating to MVCC and the transactional model.
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
As described in issue #111536, locks themselves don't provide isolation up to the point of commit time because once committed the lock is completely gone. Thus any concurrently committing transaction at a lower timestamp will not observe that the key was locked at the timestamp.
For replicated locks we solved this by always updating the timestamp cache when releasing a lock. The timestamp cache then ensures that any concurrently writing transaction cannot write at a time lower than the commit timestamp when we held a lock.
We don't do the same for replicated locks. Thus, even an unreplicated lock is held all the way until commit time, it may not provide isolation up to the commit timestamp.
While we could also update the timestamp cache for all replicated locks, this has a few items that we should consider:
Unreplicated locks are not currently reliable anyway since they can be lost. Thus, we would be doing more work for every unreplicated lock and still would not be able to provide an isolation guarantee. See concurrency: unreplicated lock loss detection #142977 for further discussion.
Without further work, this would also require disabling 1PC for any transaction that takes out a replicated lock.
cockroach/pkg/kv/kvclient/kvcoord/txn_interceptor_committer.go
Lines 555 to 595 in d6ca127
Jira issue: CRDB-48612
The text was updated successfully, but these errors were encountered: