mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-06 21:52:54 +08:00
fix: close it after using sql.Rows
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user