40 Commits

Author SHA1 Message Date
c4d3eb1cd0 Remove support for Google Spanner database. (#105846)
* Remove support for Google Spanner database.
2025-05-23 11:35:59 +02:00
694b9dfe50 Chore: Replace xorm.io/xorm imports (#104458)
* replace xorm.io/xorm imports

* replace xorm from other go.mod files

* clean up workspace

* nolint does not make sense anymore as it is not a module

* try if nolint directive helps

* use nolint:all for xorm

* add more nolints

* try to skip xorm in linter config

* exclude xorm differently

* retrigger ci
2025-05-02 17:13:01 +02:00
047f5edae9 Chore: Add xorm.io/core into xorm (#103700)
* add xorm.io/core into xorm

* update workspace

* format imports

* update workspace
2025-04-16 08:58:50 +02:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
413378dd3a Retry aborted transactions on Spanner. (#103289)
* Retry aborted transactions on Spanner.
2025-04-03 16:26:09 +02:00
0ce67dad74 Spanner: support for lastInsertId (#101770)
* Support for returning inserted ID in Spanner.
* Convert bytes to string when storing them into text column.
2025-03-10 15:59:06 +01:00
d4916207a0 chore(tracing): add tracing for frontend and db session (#91509)
This PR adds instrumentation for loading frontend SPA along with select methods in the dashboard service, and cleans up span handling in sqlstore.

---------

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2024-08-05 17:17:39 -08:00
f5da9edbba Chore: Remove unused method in db.DB (#90433)
* remove unused method

* clean up tests
2024-07-17 08:17:23 +02:00
99d8025829 Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
e4c1a7a141 Tracing: Standardize on otel tracing (#75528) 2023-10-03 14:54:20 +02:00
025b2f3011 Chore: use any rather than interface{} (#74066) 2023-08-30 18:46:47 +03:00
040b7d2571 Chore: Add errutils helpers (#73577)
Add helpers for the errutil package in favor of errutil.NewBase.
2023-08-22 12:52:24 +02:00
41843464d1 SQLStore: Fix SQLite error propagation if query retries are disabled (#64904)
* SQLStore: Add test when query retrying is disabled

* Fix condition

* Add test cases for sqlite3.ErrLocked
2023-03-17 12:57:13 +02:00
89569be3a6 SQLStore: Fix wrong usage of xorm's insert functions in tests (#63850)
* SQLStore: Fix InsertId

* Prefs: Fix Insert return value

* Fix tests

* Add guidelines
2023-03-02 13:01:36 +02:00
bc2813ef06 Chore: Fix goimports grouping in pkg/services (#62420)
* fix goimports

* fix goimports order
2023-01-30 08:21:27 +00:00
2b0de82aa9 SQLStore: Add test for nested transactions events (#60500)
* SQLStore: Add test for nested transactions events

* Replace fmt.Print* with t.Log*

* Add different test cases
2023-01-23 14:17:56 +01:00
9f503a261a Traces: Create span when a new session is opened (#61115) 2023-01-09 09:41:15 -05:00
cc007e9727 chore: sqlstore cleanup (#60415)
* chore: remove unused test helper from sqlstore

TimeNow() is no longer used in any tests in this package.

* chore: move sqlstore.SQLBuilder to the infra/db package

This required some minor refactoring; we need to be a little more explicit about passing around the dialect and engine. On the other hand, that's a few fewer uses of the `dialect` global constant!

* chore: move UserDeletions into the only package using it

* cleanup around moving sqlbuilder

* remove dialect and sqlog global vars

* rename userDeletions to serviceAccountDeletions
2022-12-16 11:09:06 -05:00
8ab7ca45cd Nested folder: Fix for PostgreSQL (#59405)
* Nested Folders: Fix PostgreSQL LastInsertId failure

* Fix children sorting

* Fix store tests
2022-11-28 17:48:44 +02:00
f3da48bd50 SQLStore: Refactor query retries to use exponential backoff (#58559) 2022-11-24 13:12:50 +02:00
46fb4081ba SQLStore: Optionally retry queries if sqlite returns database is locked (#56096)
* SQLStore: Retry queries if sqlite returns database is locked

* Configurable retries

* Apply suggestions from code review

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2022-10-17 21:23:44 +03:00
8b77ee2734 SQLStore: Ensure that sessions are always closed (#55864)
* SQLStore: Ensure that sessions are always closed

Delete `NewSession()` in favour of `WithDbSession()`

* Add WithDbSessionForceNewSession to the interface

* Apply suggestions from code review
2022-09-29 15:55:47 +03:00
7b4cea8151 Chore: StoreSplit tag service (#55453)
* move tag service outside

* fix dashboard

* fix test

* lint

* fix linter

* remove spew
2022-09-21 08:04:01 -04:00
862a6a2fa6 Logging: Introduce API for contextual logging (#55198)
Introduces a FromContext method on the log.Logger interface that 
allows contextual key/value pairs to be attached, e.g. per request, 
so that any logger using this API will automatically get the per request 
context attached. The proposal makes the traceID available for 
contextual logger , if available, and would allow logs originating from 
a certain HTTP request to be correlated with traceID.
In addition, when tracing not enabled, skip adding
traceID=00000000000000000000000000000000
to logs.
2022-09-20 18:32:06 +02:00
6c43eb0b4d Split Create User (#50502)
* Split Create User

* Use new create user and User from package user

* Add service to wire

* Making create user work

* Replace user from user pkg

* One more

* Move Insert to orguser Service/Store

* Remove unnecessary conversion

* Cleaunp

* Fix Get User and add fakes

* Fixing get org id for user logic, adding fakes and other adjustments

* Add some tests for ourguser service and store

* Fix insert org logic

* Add comment about deprecation

* Fix after merge with main

* Move orguser service/store to org service/store

* Remove orguser from wire

* Unimplement new Create user and use User from pkg user

* Fix wire generation

* Fix lint

* Fix lint - use only User and CrateUserCommand from user pkg

* Remove User and CreateUserCommand from models

* Fix lint 2
2022-06-28 14:32:25 +02:00
8e606dd751 Chore: Remove x from session (#48074) 2022-04-21 13:20:18 -04:00
6a7a486c6f Reuse opened session in the context (#44939) 2022-02-08 09:02:23 -05:00
dca3dddafd Add store interface (#44694)
* Add store interface

* Fix lint
2022-02-01 14:51:22 +01:00
a10fa5cad3 Instrumentation: Start tracing database requests (#34572)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-05-27 13:55:33 +02:00
5a0780801b SQLStore: Close session in withDbSession (#31775)
* 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>
2021-03-18 14:27:59 +01:00
b5379c5335 Chore: Fix SQL related Go variable naming (#28887)
* Chore: Fix variable naming

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-11 06:21:08 +01:00
a2fbffe48a Server: Add health check route (#26999)
* Server: Add health check route

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

* Server: Remove health check middleware

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-08-18 14:58:08 +02:00
ea35ae4d1f Chore: Update the xorm dependency (#22376)
* Upgrade xorm

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-04-01 15:57:21 +02:00
3798ac903d Upgrade golangci-lint and fixes some linting errors. (#22909)
Example: https://play.golang.org/p/cfPIPG3BwjJ
2020-03-23 13:37:53 +01:00
2a78d2a61c pkg/services: Check errors (#19712)
* pkg/services: Check errors
* pkg/services: Don't treat context.Canceled|context.DeadlineExceeded as error
2019-10-22 14:08:18 +02:00
3dbc3251d1 Chore: Deduplicate sqlstore transaction code (#17069)
* Deduplicate transaction code

* More deduplication
2019-05-16 12:39:59 +02:00
3479cf4b39 expose functions to use sessions 2018-06-18 14:50:36 +02:00
da91b91b4b transactions: start sessions and transactions at the same place
this make it possible for handler to use `withSession` when
transactions is not nedded and `inTransactionCtx` if its needed
without knowing who owns the session/transaction
2018-06-15 20:52:57 +02:00
9ca9a7c302 bus: dont start transaction when creating session 2018-06-15 12:46:20 +02:00
442e0e437b refactoring: transaction manager PR #12203 2018-06-15 12:46:20 +02:00