Question about concurrency control

I am wondering that how CRDB designed the concurrency control. I read codes in mvcc.go and still do not have a thorough understand about this part.
Could anyone give me some advice on CC of CRDB or any documents on the design?
Thank you very much :slight_smile:

Hey @lemon,

Thanks for reaching out, were there any specific questions you had about concurrency control on CRDB?

We have some documentation around how we use mvcc here, but this does not delve to deep into the design of mvcc specifically. Let me know if this helps, or if you have any specific questions that we could answer.



Hey @ronarev,
Sorry for late reply.
I see you use epoch in Transaction design. I wonder that how you synchronize epoch in a distributed system. I think, this synchronization may bring some overhead.
And how CRDB synchronizes timestamp between different nodes which may have different clock?

Hi @lemon,

CockroachDB relies on a NTP or other clock synchronization software to keep the clocks from drifting too far apart. In the event that a clock on a different node drifts too far (500ms by default), that node would shut down spontaneously. You can read more about clock synchronization here.

Let me know if you have any more questions.



There might be some confusion here. A transaction’s epoch is not a distributed thing. Each transaction is “coordinated” by one node (that node with the SQL connection that started that transaction). Transactions have to restart sometimes, at which point this coordinator increments the txn’s epoch. There’s nothing to coordinate about it.

Generally for concurrency control see this old blog post

and docs around here

@ronarev, thank you so much!

Hi @andrei,
I got incorrect understanding about the codes :worried:
Thank you for your reply.

1 Like