Skip to content

Commit

Permalink
fix: ignore errors if transaction has closed already (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay authored Aug 20, 2024
1 parent 0658bbe commit 53c11d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/storage/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ func (c *Connection) Transaction(fn func(*Connection) error) error {
return err
}
}); terr != nil {
return terr
// there exists a race condition when the context deadline is exceeded
// and whether the transaction has been committed or not
// e.g. if the context deadline has exceeded but the transaction has already been committed,
// it won't be possible to perform a rollback on the transaction since the transaction has been closed
if !errors.Is(terr, sql.ErrTxDone) {
return terr
}
}
return returnErr
}
Expand Down

0 comments on commit 53c11d1

Please sign in to comment.