From c987d50f240b678f459bfe510233474bb7ee893a Mon Sep 17 00:00:00 2001 From: kim Date: Sun, 5 May 2024 23:06:43 +0100 Subject: [PATCH] don't use timeout context on close --- internal/db/sqlite/driver.go | 11 +---------- internal/db/sqlite/driver_wasmsqlite3.go | 11 ----------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/internal/db/sqlite/driver.go b/internal/db/sqlite/driver.go index 1f45b21e1..11cb6b27d 100644 --- a/internal/db/sqlite/driver.go +++ b/internal/db/sqlite/driver.go @@ -22,7 +22,6 @@ package sqlite import ( "context" "database/sql/driver" - "time" "modernc.org/sqlite" @@ -96,17 +95,9 @@ func (c *sqliteConn) QueryContext(ctx context.Context, query string, args []driv } func (c *sqliteConn) Close() (err error) { - ctx := context.Background() - - // Set a timeout context to limit execution time. - ctx, cncl := context.WithTimeout(ctx, 5*time.Second) - // see: https://www.sqlite.org/pragma.html#pragma_optimize const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;" - _, _ = c.connIface.ExecContext(ctx, onClose, nil) - - // Done. - cncl() + _, _ = c.connIface.ExecContext(context.Background(), onClose, nil) // Finally, close the conn. err = c.connIface.Close() diff --git a/internal/db/sqlite/driver_wasmsqlite3.go b/internal/db/sqlite/driver_wasmsqlite3.go index 33788106f..afe499a98 100644 --- a/internal/db/sqlite/driver_wasmsqlite3.go +++ b/internal/db/sqlite/driver_wasmsqlite3.go @@ -22,7 +22,6 @@ package sqlite import ( "context" "database/sql/driver" - "time" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -110,23 +109,13 @@ func (c *sqliteConn) ExecContext(ctx context.Context, query string, args []drive } func (c *sqliteConn) Close() (err error) { - ctx := context.Background() - // Get acces the underlying raw sqlite3 conn. raw := c.connIface.(sqlite3.DriverConn).Raw() - // Set a timeout context to limit execution time. - ctx, cncl := context.WithTimeout(ctx, 5*time.Second) - old := raw.SetInterrupt(ctx) - // see: https://www.sqlite.org/pragma.html#pragma_optimize const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;" _ = raw.Exec(onClose) - // Unset timeout context. - _ = raw.SetInterrupt(old) - cncl() - // Finally, close. err = raw.Close() return