cockroachdb / cockroachdb/cockroach
sql: lock only necessary column families from SELECT FOR UPDATE
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
In 23.2 we added a new implementation of SELECT FOR UPDATE, which is initially used only for Read Committed isolation (and Serializable isolation when `optimizer_use_lock_op_for_serializable` is true). As of https://github.com/cockroachdb/cockroach/pull/116170 this implementation of SELECT FOR UPDATE locks _all_ column families of selected rows.
Separate column families are often used to reduce accidental contention. Locking all column families in SFU is simple and easy to understand, but might prevent separate column families from being an effective solution for accidental contention. It would be nice to give users control over exactly which column families are locked by SELECT FOR UPDATE.
In https://github.com/cockroachdb/cockroach/pull/116170 we tried using the projection list to pick which column families to lock, but ran into cases like `SELECT 1 FROM foo FOR UPDATE` or `SELECT a + b FROM foo FOR UPDATE`. I think a more intentional syntax like `SELECT 1 FROM foo FOR UPDATE OF foo (a, b)` would be easier to understand, though it would require application changes to take advantage of.
Jira issue: CRDB-34804
Epic CRDB-38938
Contributor guide
Assessment
This issue has not been assessed yet.