2 phase transaction protocol

(AJPham) #1

Hi, everyone.
I read and don’t understand your 2 phase transaction protocol. In phase 2, when transaction record update to aborted? And i read “CockroachDB checks the running transaction’s record to see if it’s been ABORTED; if it has, it restarts the transaction”. When does a transaction restart occur? What if the restart is still aborted ?

And phase 3, if phase 2 has restarted transaction when state transaction record is aborted, How can phase 3 encounter the status of the transaction record is aborted.

I see conflicts. Can you explain me the 2PC process?

(Ron Arévalo) #2

Hey @AJPham,

Thanks for reaching out!

Regarding your question, the document you quote here:

The ‘it’ in this means that the transaction will throw a 40001 error when it fails and must be restarted on the client side, we have more information about that here.

If a transaction keeps failing, you’d need to ask why it failed in the first place, this usually is a sign of some contention.

In some cases, transactions will be automatically restarted by CRDB internally, this is usually the case for individual statements and batched statements, you can read more about retries here.

Let me know if this helps, or if you have any other questions.



(AJPham) #3

thank you. I understand