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 wal mode by default (#10822)

Vikrant Gupta13249b5e691f
diff --git a/.github/workflows/integrationci.yaml b/.github/workflows/integrationci.yaml
index 59c0498696..cf0882703e 100644
--- a/.github/workflows/integrationci.yaml
+++ b/.github/workflows/integrationci.yaml
@@ -55,6 +55,9 @@ jobs:
sqlstore-provider:
- postgres
- sqlite
+ sqlite-mode:
+ - delete
+ - wal
clickhouse-version:
- 25.5.6
- 25.12.5
@@ -62,6 +65,9 @@ jobs:
- v0.142.0
postgres-version:
- 15
+ exclude:
+ - sqlstore-provider: postgres
+ sqlite-mode: wal
if: |
((github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))) && contains(github.event.pull_request.labels.*.name, 'safe-to-integrate')
@@ -102,6 +108,7 @@ jobs:
--basetemp=./tmp/ \
src/${{matrix.src}} \
--sqlstore-provider ${{matrix.sqlstore-provider}} \
+ --sqlite-mode ${{matrix.sqlite-mode}} \
--postgres-version ${{matrix.postgres-version}} \
--clickhouse-version ${{matrix.clickhouse-version}} \
--schema-migrator-version ${{matrix.schema-migrator-version}}
diff --git a/conf/example.yaml b/conf/example.yaml
index 77fe4fb885..612b6f2b91 100644
--- a/conf/example.yaml
+++ b/conf/example.yaml
@@ -86,7 +86,7 @@ sqlstore:
# The path to the SQLite database file.
path: /var/lib/signoz/signoz.db
# The journal mode for the sqlite database. Supported values: delete, wal.
- mode: delete
+ mode: wal
# The timeout for the sqlite database to wait for a lock.
busy_timeout: 10s
# The default transaction locking behavior. Supported values: deferred, immediate, exclusive.
diff --git a/docs/contributing/go/integration.md b/docs/contributing/go/integration.md
index 20afd8fdaa..7a12e7dbcc 100644
--- a/docs/contributing/go/integration.md
+++ b/docs/contributing/go/integration.md
@@ -193,6 +193,7 @@ uv run pytest --basetemp=./tmp/ -vv --reuse src/passwordauthn/01_register.py::te
Tests can be configured using pytest options:
- `--sqlstore-provider` - Choose database provider (default: postgres)
+- `--sqlite-mode` - SQLite journal mode: `delete` or `wal` (default: delete). Only relevant when `--sqlstore-provider=sqlite`.
- `--postgres-version` - PostgreSQL version (default: 15)
- `--clickhouse-version` - ClickHouse version (default: 25.5.6)
- `--zookeeper-version` - Zookeeper version (default: 3.7.1)
@@ -202,7 +203,6 @@ Example:
uv run pytest --basetemp=./tmp/ -vv --reuse --sqlstore-provider=postgres --postgres-version=14 src/auth/
```
-
## What should I remember?
- **Always use the `--reuse` flag** when setting up the environment to keep containers running
@@ -213,3 +213,4 @@ uv run pytest --basetemp=./tmp/ -vv --reuse --sqlstore-provider=postgres --postg
- **Use descriptive test names** that clearly indicate what is being tested
- **Leverage fixtures** for common setup and authentication
- **Test both success and failure scenarios** to ensure robust functionality
+- **`--sqlite-mode=wal` does not work on macOS.** The integration test environment runs SigNoz inside a Linux container with the SQLite database file mounted from the macOS host. WAL mode requires shared memory between connections, and connections crossing the VM boundary (macOS host ↔ Linux container) cannot share the WAL index, resulting in `SQLITE_IOERR_SHORT_READ`. WAL mode is tested in CI on Linux only.
diff --git a/pkg/sqlstore/config.go b/pkg/sqlstore/config.go
index b2e96f1479..cb02c42820 100644
--- a/pkg/sqlstore/config.go
+++ b/pkg/sqlstore/config.go
@@ -53,7 +53,7 @@ func newConfig() factory.Config {
},
Sqlite: SqliteConfig{
Path: "/var/lib/signoz/signoz.db",
- Mode: "delete",
+ Mode: "wal",
BusyTimeout: 10000 * time.Millisecond, // increasing the defaults from https://github.com/mattn/go-sqlite3/blob/master/sqlite3.go#L1098 because of transpilation from C to GO
TransactionMode: "deferred",
},
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py
index fe35aedd5d..83e47e2ef6 100644
--- a/tests/integration/conftest.py
+++ b/tests/integration/conftest.py
@@ -50,6 +50,12 @@ def pytest_addoption(parser: pytest.Parser):
default="postgres",
help="sqlstore provider",
)
+ parser.addoption(
+ "--sqlite-mode",
+ action="store",
+ default="delete",
+ help="sqlite mode",
+ )
parser.addoption(
"--postgres-version",
action="store",
diff --git a/tests/integration/fixtures/sqlite.py b/tests/integration/fixtures/sqlite.py
index b22202af5d..8b55f57652 100644
--- a/tests/integration/fixtures/sqlite.py
+++ b/tests/integration/fixtures/sqlite.py
@@ -28,6 +28,7 @@ def sqlite(
result = conn.execute(sql.text("SELECT 1"))
assert result.fetchone()[0] == 1
+ mode = pytestconfig.getoption("--sqlite-mode")
return types.TestContainerSQL(
container=types.TestContainerDocker(
id="",
@@ -38,6 +39,7 @@ def sqlite(
env={
"SIGNOZ_SQLSTORE_PROVIDER": "sqlite",
"SIGNOZ_SQLSTORE_SQLITE_PATH": str(path),
+ "SIGNOZ_SQLSTORE_SQLITE_MODE": mode,
},
)
diff --git a/tests/integration/src/querier/03_metrics.py b/tests/integration/src/querier/03_metrics.py
index 0e2b7c293e..75eadc083b 100644
--- a/tests/integration/src/querier/03_metrics.py
+++ b/tests/integration/src/querier/03_metrics.py
@@ -12,10 +12,10 @@ from fixtures.querier import (
assert_minutely_bucket_values,
build_builder_query,
find_named_result,
- index_series_by_label,
- make_query_request,
get_all_warnings,
get_error_message,
+ index_series_by_label,
+ make_query_request,
)
from fixtures.utils import get_testdata_file_path