Transaction retries and aborts

I have a situation whereby I need to differentiate between a transaction retry situation and a transaction abort due to conflict. In the retry scenario I do want to implement client side retries: this should be done when a situation arises such as a key range partition.

When one transaction with a higher priority conflicts with a lower priority transaction which causes the lower priority transaction to abort, I want to treat this differently in that I do not want to retry.

Having done some tests around the conflict scenario, the exception raised is still a transaction retry instance with sql state “40001”. Apart from parsing the exception message for say “ABORT_REASON_CLIENT_REJECT”, how can I tell these 2 situation apart?

Hi Mark,

Try giving this a read:

https://www.cockroachlabs.com/docs/stable/show-trace.html

Thanks,
Matt

I’m not sure how that tracing will help me? All I have to work with in the code is the exception raised from the database. As I mentioned I’d rather not have to test the exception message for a specific string…