SQL: close rows to release connection (#97147)

* SQL: close rows to release connection

* dont return err from rows.Close()
pull/97170/head
Matheus Macabu 7 months ago committed by GitHub
parent 0bf9d68070
commit f2b96593ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      pkg/services/accesscontrol/database/policies.go
  2. 5
      pkg/services/playlist/playlistimpl/xorm_store.go
  3. 5
      pkg/storage/unified/search/document.go
  4. 10
      pkg/storage/unified/sql/backend.go
  5. 4
      pkg/storage/unified/sql/dbutil/dbutil.go
  6. 2
      pkg/storage/unified/sql/queries.go

@ -42,6 +42,9 @@ func GetAccessPolicies(ctx context.Context, orgID int64, sql *session.SessionDB,
if err != nil {
return nil, err
}
defer func() {
_ = rows.Close()
}()
created := time.Now()
updated := time.Now()

@ -222,6 +222,11 @@ func (s *sqlStore) ListAll(ctx context.Context, orgId int64) ([]playlist.Playlis
if err != nil {
return nil, err
}
defer func() {
_ = rows.Close()
}()
for rows.Next() {
err = rows.Scan(&playlistId, &itemType, &itemValue)
if err != nil {

@ -29,6 +29,11 @@ func (s *StandardDocumentBuilders) GetDocumentBuilders() ([]resource.DocumentBui
if err != nil {
return nil, err
}
defer func() {
_ = rows.Close()
}()
for rows.Next() {
info := &dashboard.DatasourceQueryResult{}
err = rows.Scan(&info.UID, &info.Type, &info.Name, &info.IsDefault)

@ -146,6 +146,11 @@ func (b *backend) Namespaces(ctx context.Context) ([]string, error) {
if err != nil {
return err
}
defer func() {
_ = rows.Close()
}()
for rows.Next() {
var ns string
err = rows.Scan(&ns)
@ -155,8 +160,7 @@ func (b *backend) Namespaces(ctx context.Context) ([]string, error) {
namespaces = append(namespaces, ns)
}
err = rows.Close()
return err
return nil
})
return namespaces, err
@ -679,7 +683,7 @@ func (b *backend) poll(ctx context.Context, grp string, res string, since int64,
nextRV = rec.ResourceVersion
prevRV := rec.PreviousRV
if prevRV == nil {
*prevRV = int64(0)
prevRV = new(int64)
}
stream <- &resource.WrittenEvent{
WriteEvent: resource.WriteEvent{

@ -165,6 +165,10 @@ func Query[T any](ctx context.Context, x db.ContextExecer, tmpl *template.Templa
return nil, err
}
defer func() {
_ = rows.Close()
}()
var ret []T
for rows.Next() {
v, err := scanRow(rows, req)

@ -101,7 +101,7 @@ func (r *sqlResourceHistoryPollRequest) Validate() error {
func (r *sqlResourceHistoryPollRequest) Results() (*historyPollResponse, error) {
prevRV := r.Response.PreviousRV
if prevRV == nil {
*prevRV = int64(0)
prevRV = new(int64)
}
return &historyPollResponse{
Key: resource.ResourceKey{

Loading…
Cancel
Save