cockroach-go icon indicating copy to clipboard operation
cockroach-go copied to clipboard

Flexible retry backoff policies

Open MattWhelan opened this issue 5 months ago • 3 comments

Extends the existing retry limit mechanism to allow for delays between retries. Includes implementations for fixed delays and exponential backoff.

MattWhelan avatar Jun 09 '25 23:06 MattWhelan

This change is Reviewable

cockroach-teamcity avatar Jun 09 '25 23:06 cockroach-teamcity

We haven’t implemented this because cockroachdb-go uses save point based retries and because of savepoint-based retries, a transaction can continue holding locks in between retries. So that means with exponential backoff, you'll be holding locks for longer, thus putting the app at even greater risk of contention.

If you could show us that this is not the case with backoffs, we will consider adding this! Thanks!

dikshant avatar Jun 10 '25 20:06 dikshant

We haven’t implemented this because cockroachdb-go uses save point based retries and because of savepoint-based retries, a transaction can continue holding locks in between retries. So that means with exponential backoff, you'll be holding locks for longer, thus putting the app at even greater risk of contention.

If you could show us that this is not the case with backoffs, we will consider adding this! Thanks!

I just pushed 9dda97b. Could you take a look at that? I'm not sure what all the implications are of separating the database transaction lifecycle from the Tx object, but aside from that, I think it's sound, and avoids the problem with holding locks during backoff.

MattWhelan avatar Jun 10 '25 22:06 MattWhelan