From 16eb2059969357addbfb28c74f23624f011f3e48 Mon Sep 17 00:00:00 2001 From: Anton Tolchanov Date: Thu, 5 Feb 2026 15:18:59 +0000 Subject: [PATCH] sqlite: don't interrupt a running query if closed Updates tailscale/corp#36170 Signed-off-by: Anton Tolchanov --- sqlite.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sqlite.go b/sqlite.go index 04c39f6..abec629 100644 --- a/sqlite.go +++ b/sqlite.go @@ -579,7 +579,11 @@ func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (drive // Note: We respond to cancellation on the primary context (ctx) not // the cleanup context (pctx). if ctx.Err() != nil { - db.Interrupt() + if s.closed.Load() { + UsesAfterClose.Add("stmt.ExecContext.Interrupt", 1) + } else { + db.Interrupt() + } } }) @@ -652,7 +656,11 @@ func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driv // Note: We respond to cancellation on the primary context (ctx) not // the cleanup context (pctx). if ctx.Err() != nil { - db.Interrupt() + if s.closed.Load() { + UsesAfterClose.Add("stmt.QueryContext.Interrupt", 1) + } else { + db.Interrupt() + } } }) // In this case we do not have an early exit, so we don't need to