Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: add a backoff to the retry loop in db.Txn #135173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miraradeva
Copy link
Contributor

In rare cases (e.g. #77376), two transactions can get repeatedly deadlocked while trying to write to same key(s): one aborts the other, but before it can proceed, the other transaction has restarted and acquired a lock on the key again. This can result in the max transaction retries being exceeded without either transaction succeeding.

This commit adds a backoff to the transaction retry loop in db.Txn, which will hopefully help one transaction slow down and let the other one commit.

Fixes: #77376

Release note: None

Copy link

blathers-crl bot commented Nov 14, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@miraradeva miraradeva force-pushed the mira-133431-backoff branch 2 times, most recently from f003a9b to 583346e Compare November 14, 2024 18:16
In rare cases (e.g. cockroachdb#77376), two transactions can get repeatedly
deadlocked while trying to write to same key(s): one aborts the other,
but before it can proceed, the other transaction has restarted and
acquired a lock on the key again. This can result in the max
transaction retries being exceeded without either transaction
succeeding.

This commit adds a backoff to the transaction retry loop in `db.Txn`,
which will hopefully help one transaction slow down and let the other
one commit.

Fixes: cockroachdb#77376

Release note: None
@miraradeva miraradeva marked this pull request as ready for review November 15, 2024 20:30
@miraradeva miraradeva requested a review from a team as a code owner November 15, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter: Add PR check to encourage including issue or epic refs in the PR/commit messages
2 participants