Avoid emitting error on transaction rollback that's complete
It's on purpose
This commit is contained in:
parent
347f62bd6d
commit
60bf09e813
2 changed files with 11 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue