mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQL: close rows to release connection (#97147)
* SQL: close rows to release connection * dont return err from rows.Close()
This commit is contained in:
parent
0bf9d68070
commit
f2b96593ea
@ -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…
Reference in New Issue
Block a user