How to use non retry transaction with SNAPSHOT_ISOLATION?

The transaction doc says

Note that these types of transaction retries do not occur for transactions executing with the snapshot isolation level.

As per the doc then will the transaction flow in SNAPSHOT_ISOLATION look like below -

BEGIN 
<transaction statement>
COMMIT

If yes then what all error cases can come up in the above flow? What if there is an exception while doing commit?

Can someone provide me a simple example of java transaction with SNAPSHOT_ISOLATION ?

Hi @tuk. I looked into this and “these types of transaction retries” seems
to be a little vague. I’m following up with our docs team to get this
language tightened up a bit.

Because of the way the CockroachDB internals work, there will always be a
chance that transactions may need to be retried, so you’ll need the same
retry loop as if you were using SERIALIZABLE. However, we are currently in
the middle of an effort to retry many more queries server-side than before,
so you should see the number of these go down as we make progress.

I also filed an issue with an idea for how to avoid the RETRY_DELETE_RANGE
issue you saw in the other thread:

Thanks @Dan.

Now the doc for Java only have an example for doing transaction with client side retry. Can you also update the doc for java on how to do a transaction without retry? Not all application might want to use client side retry.

Hi @tuk. Thanks for the feedback! I’ve passed it on to the docs team.

If you don’t want to retry, then you don’t need to do anything cockroach-specific. Just do your transaction in the same way you would on PostgreSQL. There’s no reason to do the savepoint calls if you’re not going to use the retry loop.