Fix unclosed DB transactions in subscriber search
This commit is contained in:
parent
6b6dc59067
commit
6747a95b3d
|
@ -110,6 +110,7 @@ func (q *Queries) compileSubscriberQueryTpl(exp string, db *sqlx.DB) (string, er
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
// Perform the dry run.
|
||||
if exp != "" {
|
||||
|
@ -117,7 +118,6 @@ func (q *Queries) compileSubscriberQueryTpl(exp string, db *sqlx.DB) (string, er
|
|||
}
|
||||
stmt := fmt.Sprintf(q.QuerySubscribersTpl, exp)
|
||||
if _, err := tx.Exec(stmt, true, pq.Int64Array{}); err != nil {
|
||||
tx.Rollback()
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
|
|
@ -114,10 +114,10 @@ func handleQuerySubscribers(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusInternalServerError,
|
||||
fmt.Sprintf("Error preparing query: %v", pqErrMsg(err)))
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
// Run the query.
|
||||
if err := tx.Select(&out.Results, stmt, listIDs, "id", pg.Offset, pg.Limit); err != nil {
|
||||
tx.Rollback()
|
||||
return echo.NewHTTPError(http.StatusInternalServerError,
|
||||
fmt.Sprintf("Error querying subscribers: %v", pqErrMsg(err)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue