From 60bf09e813202db31e8eaa3c985843d633b91e3b Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 4 May 2026 19:53:36 +0000 Subject: [PATCH] Avoid emitting error on transaction rollback that's complete It's on purpose --- lint/error.go | 10 ++++++++++ platform/email/template.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lint/error.go b/lint/error.go index f9433d2d..ae76d3ba 100644 --- a/lint/error.go +++ b/lint/error.go @@ -23,3 +23,13 @@ func LogOnErrCtx(f ErrorableCtx, ctx context.Context, msg string) { log.Error().Err(e).Msg(msg) } } +func LogOnErrRollback(f ErrorableCtx, ctx context.Context, msg string) { + e := f(ctx) + if e != nil { + // We're fine with rollbacks that are already properly closed + if e.Error() == "sql: transaction has already been committed or rolled back" { + return + } + log.Error().Err(e).Msg(msg) + } +} diff --git a/platform/email/template.go b/platform/email/template.go index c5738c48..c951aa3c 100644 --- a/platform/email/template.go +++ b/platform/email/template.go @@ -68,7 +68,7 @@ func LoadTemplates() error { if err != nil { return fmt.Errorf("Failed to start transaction: %w", err) } - defer lint.LogOnErrCtx(tx.Rollback, ctx, "rollback") + defer lint.LogOnErrRollback(tx.Rollback, ctx, "rollback") templateByID = make(map[int32]*builtTemplate, 0) for name, p := range all_templates { template_id, err := templateDBID(tx, name, p)