summaryrefslogtreecommitdiff
path: root/internal/db/bundb/errors.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-03-07 13:56:33 +0000
committerLibravatar GitHub <noreply@github.com>2024-03-07 14:56:33 +0100
commit016923b4dc0575c92eb0507a5c527f3183ec52f1 (patch)
tree29909054fbb87ec7ffb14b166fd1a9a6181dd26b /internal/db/bundb/errors.go
parent[docs/chore] Swagger fixes for filters (#2730) (diff)
downloadgotosocial-016923b4dc0575c92eb0507a5c527f3183ec52f1.tar.xz
[bugfix] add workaround for Xsqlite_interrupt() permanently breaking connection (#2731)
Diffstat (limited to 'internal/db/bundb/errors.go')
-rw-r--r--internal/db/bundb/errors.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/db/bundb/errors.go b/internal/db/bundb/errors.go
index c8f39aebd..ddbb302f8 100644
--- a/internal/db/bundb/errors.go
+++ b/internal/db/bundb/errors.go
@@ -18,6 +18,7 @@
package bundb
import (
+ "database/sql/driver"
"errors"
"github.com/jackc/pgx/v5/pgconn"
@@ -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