Skip to content
Snippets Groups Projects
Commit 66e3f754 authored by Simon Künzel's avatar Simon Künzel
Browse files

Improve transaction conflict handling

parent 156be9f5
No related branches found
No related tags found
No related merge requests found
Pipeline #7572 passed
Pipeline: backend

#7573

    import os
    import random
    import sys
    import time
    from enum import StrEnum
    from typing import Callable, TypeVar, TypeVarTuple, Sequence
    ......@@ -218,6 +220,9 @@ class Database:
    if attempts >= (self._max_write_attempts if writeable else self._max_read_attempts):
    self._on_transaction_aborted_after_repeated_conflict(writeable)
    raise TransactionConflictError(e)
    # Sleep a random time for up to 500ms to increase chance that next attempt succeeds (The randomness makes
    # it more likely that we reattempt at a different time than the one with which we are in conflict right now)
    time.sleep(random.random() / 2)
    continue
    raise AssertionError("This should be unreachable code")
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment