Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(sqlstore): enable transaction_mode immediate (#10825)

Vikrant Gupta0e97204c772b
diff --git a/ee/modules/dashboard/impldashboard/module.go b/ee/modules/dashboard/impldashboard/module.go
index fe7e79e91e..57a197063c 100644
--- a/ee/modules/dashboard/impldashboard/module.go
+++ b/ee/modules/dashboard/impldashboard/module.go
@@ -143,7 +143,7 @@ func (module *module) Delete(ctx context.Context, orgID valuer.UUID, id valuer.U
}
err = module.store.RunInTx(ctx, func(ctx context.Context) error {
- err := module.deletePublic(ctx, orgID, id)
+ err := module.store.DeletePublic(ctx, id.String())
if err != nil && !errors.Ast(err, errors.TypeNotFound) {
return err
}
@@ -216,7 +216,3 @@ func (module *module) Update(ctx context.Context, orgID valuer.UUID, id valuer.U
func (module *module) LockUnlock(ctx context.Context, orgID valuer.UUID, id valuer.UUID, updatedBy string, isAdmin bool, lock bool) error {
return module.pkgDashboardModule.LockUnlock(ctx, orgID, id, updatedBy, isAdmin, lock)
}
-
-func (module *module) deletePublic(ctx context.Context, _ valuer.UUID, dashboardID valuer.UUID) error {
- return module.store.DeletePublic(ctx, dashboardID.StringValue())
-}
diff --git a/pkg/modules/dashboard/impldashboard/store.go b/pkg/modules/dashboard/impldashboard/store.go
index 960aa2e9be..6caa0f5730 100644
--- a/pkg/modules/dashboard/impldashboard/store.go
+++ b/pkg/modules/dashboard/impldashboard/store.go
@@ -184,7 +184,7 @@ func (store *store) UpdatePublic(ctx context.Context, storable *dashboardtypes.S
func (store *store) Delete(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error {
_, err := store.
sqlstore.
- BunDB().
+ BunDBCtx(ctx).
NewDelete().
Model(new(dashboardtypes.StorableDashboard)).
Where("id = ?", id).
@@ -200,7 +200,7 @@ func (store *store) Delete(ctx context.Context, orgID valuer.UUID, id valuer.UUI
func (store *store) DeletePublic(ctx context.Context, dashboardID string) error {
_, err := store.
sqlstore.
- BunDB().
+ BunDBCtx(ctx).
NewDelete().
Model(new(dashboardtypes.StorablePublicDashboard)).
Where("dashboard_id = ?", dashboardID).
diff --git a/pkg/modules/serviceaccount/implserviceaccount/store.go b/pkg/modules/serviceaccount/implserviceaccount/store.go
index d8c176d5ee..084dd5c96f 100644
--- a/pkg/modules/serviceaccount/implserviceaccount/store.go
+++ b/pkg/modules/serviceaccount/implserviceaccount/store.go
@@ -147,7 +147,7 @@ func (store *store) CountByOrgID(ctx context.Context, orgID valuer.UUID) (int64,
count, err := store.
sqlstore.
- BunDB().
+ BunDBCtx(ctx).
NewSelect().
Model(storable).
Where("org_id = ?", orgID).
diff --git a/tests/conftest.py b/tests/conftest.py
index f3097d3340..c8a3e9514b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -59,6 +59,12 @@ def pytest_addoption(parser: pytest.Parser):
default="delete",
help="sqlite mode",
)
+ parser.addoption(
+ "--sqlite-transaction-mode",
+ action="store",
+ default="deferred",
+ help="sqlite transaction mode",
+ )
parser.addoption(
"--postgres-version",
action="store",
diff --git a/tests/fixtures/sqlite.py b/tests/fixtures/sqlite.py
index 23ac6cedc9..da25814236 100644
--- a/tests/fixtures/sqlite.py
+++ b/tests/fixtures/sqlite.py
@@ -30,6 +30,7 @@ def sqlite(
assert result.fetchone()[0] == 1
mode = pytestconfig.getoption("--sqlite-mode")
+ transaction_mode = pytestconfig.getoption("--sqlite-transaction-mode")
return types.TestContainerSQL(
container=types.TestContainerDocker(
id="",
@@ -41,6 +42,7 @@ def sqlite(
"SIGNOZ_SQLSTORE_PROVIDER": "sqlite",
"SIGNOZ_SQLSTORE_SQLITE_PATH": str(path),
"SIGNOZ_SQLSTORE_SQLITE_MODE": mode,
+ "SIGNOZ_SQLSTORE_SQLITE_TRANSACTION__MODE": transaction_mode,
},
)