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

[bugfix] add workaround for Xsqlite_interrupt() permanently breaking connection #2731

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions internal/db/bundb/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bundb

import (
"database/sql/driver"
"errors"

"github.com/jackc/pgx/v5/pgconn"
Expand Down Expand Up @@ -75,6 +76,27 @@ func processSQLiteError(err error) error {
return errBusy
case sqlite3.SQLITE_BUSY_TIMEOUT:
return db.ErrBusyTimeout

// WORKAROUND:
// text copied from matrix dev chat:
//
// okay i've found a workaround for now. so between
// v1.29.0 and v1.29.2 (modernc.org/sqlite) is that
// slightly tweaked interruptOnDone() behaviour, which
// causes interrupt to (imo, correctly) get called when
// a context is cancelled to cancel the running query. the
// issue is that every single query after that point seems
// to still then return interrupted. so as you thought,
// maybe that query count isn't being decremented. i don't
// think it's our code, but i haven't ruled it out yet.
//
// the workaround for now is adding to our sqlite error
// processor to replace an SQLITE_INTERRUPTED code with
// driver.ErrBadConn, which hints to the golang sql package
// that the conn needs to be closed and a new one opened
//
case sqlite3.SQLITE_INTERRUPT:
return driver.ErrBadConn
}

return err
Expand Down