Skip to content

backoff in the transaction loop is problematic #188

Description

@ajwerner

In cockroach, when using the SAVEPOINT cockroach_restart technique to recover from serializable restarts, the transaction's locks are held across restarts. This enables liveness among contended transactions. In the driver today, there's exponential backoff in those restarts. That means that locks will be held for a long period of inactivity, exacerbating the cost of contention potentially greatly.

See

def retry_exponential_backoff(retry_count: int, max_backoff: int = 0) -> None:
"""
This is a function for an exponential back-off whenever we encounter a retry error.
So we sleep for a bit before retrying,
and the sleep time varies for each failed transaction
capped by the max_backoff parameter.
:param retry_count: The number for the current retry count
:param max_backoff: The capped number of seconds for the exponential back-off
:return: None
"""
sleep_secs = uniform(0, min(max_backoff, 0.1 * (2 ** retry_count)))
sleep(sleep_secs)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions