SQLStore: Close session in withDbSession (#31775) (#32108)

* SQLStore: Close session in withDbSession

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* SQLStore.WithDbSession: Never use session from context

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit 5a0780801b)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-03-19 10:11:26 +01:00
committed by GitHub
co-authored by Arve Knudsen
parent 5d58d0aabb
commit bc463d6a2f
8 changed files with 116 additions and 137 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ func GetAdminStats(query *models.GetAdminStatsQuery) error {
}
func GetSystemUserCountStats(ctx context.Context, query *models.GetSystemUserCountStatsQuery) error {
return withDbSession(ctx, func(sess *DBSession) error {
return withDbSession(ctx, x, func(sess *DBSession) error {
var rawSQL = `SELECT COUNT(id) AS Count FROM ` + dialect.Quote("user")
var stats models.SystemUserCountStats
_, err := sess.SQL(rawSQL).Get(&stats)