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

fix(ext/kv): retry transaction on SQLITE_BUSY errors #20189

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

losfair
Copy link
Member

@losfair losfair commented Aug 17, 2023

Properly handle the SQLITE_BUSY error code by retrying the transaction.

Also wraps database initialization logic in a transaction to protect against incomplete/concurrent initializations.

Fixes #20116.

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM!

ext/kv/sqlite.rs Outdated
Err(e) => {
if let Some(x) = e.downcast_ref::<rusqlite::Error>() {
if x.sqlite_error_code() == Some(rusqlite::ErrorCode::DatabaseBusy) {
log::warn!("kv: Database is busy, retrying");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log::warn!("kv: Database is busy, retrying");

Or use log::debug

@losfair losfair merged commit 0960e89 into denoland:main Aug 17, 2023
13 checks passed
@losfair losfair deleted the fix-kv-sqlite-concurrency branch August 17, 2023 10:53
littledivy pushed a commit to littledivy/deno that referenced this pull request Aug 21, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes denoland#20116.
littledivy pushed a commit that referenced this pull request Aug 21, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes #20116.
losfair added a commit to losfair/deno that referenced this pull request Aug 24, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes denoland#20116.
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.

KV: Panic because sqlite DB is locked
2 participants