Merge pull request #12742 from rainzm/automated-cherry-pick-of-#12740-upstream-release-3.7

Automated cherry pick of #12740: fix: close it after using sql.Rows
This commit is contained in:
Zexi Li
2021-11-25 21:35:50 +08:00
committed by GitHub
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -336,6 +336,7 @@ func (manager *SMonitorResourceManager) GetPropertyAlert(ctx context.Context, us
if err != nil {
return nil, errors.Wrap(err, "getMonitorResourceAlert query err")
}
defer rows.Close()
total := int64(0)
resTypeDict := jsonutils.NewDict()
for rows.Next() {
+2 -1
View File
@@ -551,10 +551,11 @@ func dataCleaning(tableName string) error {
monthsDaysAgo,
)
q := sqlchemy.NewRawQuery(sqlStr)
_, err := q.Rows()
rows, err := q.Rows()
if err != nil {
return errors.Wrapf(err, "unable to delete expired data in %q", tableName)
}
defer rows.Close()
log.Infof("delete expired data in %q successfully", tableName)
return nil
}