Skip to content

Conversation

@aruiz14
Copy link
Contributor

@aruiz14 aruiz14 commented Nov 28, 2025

Issue: rancher/rancher#52872

Detect SQLITE_BUSY and SQLITE_BUSY_SNAPSHOT which can happen normally on a concurrent system using WAL mode. Retry them automatically, since that specific case won't be managed by the busy handler.

Note: BeginTx returns a *sql.Tx which does not expose any public field, so I have to introduce a new interface in order to be able to mock it for my unit tests. Other kind of testing would be challenging since this patch is meant to mitigate a possible race condition.

@aruiz14 aruiz14 requested a review from a team as a code owner November 28, 2025 16:43
@aruiz14 aruiz14 force-pushed the retry-withTransaction-on-busy-errors branch from 0f5adc0 to 83df783 Compare November 28, 2025 16:48
@aruiz14 aruiz14 force-pushed the retry-withTransaction-on-busy-errors branch from 83df783 to 81d72c7 Compare December 9, 2025 16:20

informerObjectCachePerms fs.FileMode = 0o600

maxBeginTXAttemptsOnBusyErrors = 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose this value via config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I have mixed feelings, it's probably something we will never need to tweak.
The error we are trying to mitigate is very specific and unlikely to happen, but still possible, and the only way to deal with it is to retry.
If it happens more than 3 times in a row it may be a sign of a bigger problem and we may not want to allow to ignore that?

Copy link
Contributor

@ericpromislow ericpromislow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine with the suggestion

@aruiz14 aruiz14 force-pushed the retry-withTransaction-on-busy-errors branch from 81d72c7 to 8bdc4b5 Compare December 16, 2025 10:05
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.

2 participants