Skip to content

Commit 6a29e59

Browse files
yhabteaboxzi
authored andcommitted
database.ForEachRow: Make sure to release semaphore
Imported from Icinga/icinga-notifications@d3f7eae
1 parent c5e7abe commit 6a29e59

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

database/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func ForEachRow[Row, Id any](ctx context.Context, db *DB, idColumn string, ids [
7575
if err := sem.Acquire(ctx, 1); err != nil {
7676
return errors.Wrapf(err, "cannot acquire semaphore for table %q", table)
7777
}
78+
defer sem.Release(1)
7879

7980
query := fmt.Sprintf("%s WHERE %q IN (?)", db.BuildSelectStmt(subject, subject), idColumn)
8081
stmt, args, err := sqlx.In(query, ids)

0 commit comments

Comments
 (0)