Skip to content

Commit

Permalink
fix(session): Use transaction when closing orphaned connections
Browse files Browse the repository at this point in the history
This was opening a transaction, but then calling the original reader
instead of using the reader/writer from the transaction. This would
result in a transaction being opend, then a separate transaction being
used to run the query, and finally the original transaction would
commit without any statements being executed.
  • Loading branch information
tmessi committed Apr 3, 2024
1 parent 51d33f3 commit c6349e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/session/repository_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ func (r *ConnectionRepository) closeOrphanedConnections(ctx context.Context, wor
ctx,
db.StdRetryCnt,
db.ExpBackoff{},
func(reader db.Reader, w db.Writer) error {
rows, err := r.reader.Query(ctx, fmt.Sprintf(orphanedConnectionsCte, notInClause), args)
func(_ db.Reader, w db.Writer) error {
rows, err := w.Query(ctx, fmt.Sprintf(orphanedConnectionsCte, notInClause), args)
if err != nil {
return errors.Wrap(ctx, err, op)
}
Expand Down

0 comments on commit c6349e6

Please sign in to comment.