CockroachDB is optimistically concurrent, so there is not locking. However, your use case is definitely possible.
The transaction would:
1. Read the current document (i'm assuming this needs to be done to compute the translog).
2. Read the latest ID in the translog table
3. Write a new entry to translog with ID+1
4. Write the document.
If any other transaction interleaves with this process (by either reading or writing one of the same keys in a way that would violate isolation), one of the two transactions will be aborted.
The transaction would: 1. Read the current document (i'm assuming this needs to be done to compute the translog). 2. Read the latest ID in the translog table 3. Write a new entry to translog with ID+1 4. Write the document.
If any other transaction interleaves with this process (by either reading or writing one of the same keys in a way that would violate isolation), one of the two transactions will be aborted.