Skip to content

SQLite resilience updates.#298

Merged
v0lkan merged 2 commits into
mainfrom
fix/sqlite-resilience
Jul 17, 2026
Merged

SQLite resilience updates.#298
v0lkan merged 2 commits into
mainfrom
fix/sqlite-resilience

Conversation

@v0lkan

@v0lkan v0lkan commented Jul 17, 2026

Copy link
Copy Markdown
Member

No description provided.

v0lkan added 2 commits July 16, 2026 21:37
SQLite fails transiently (SQLITE_BUSY, SQLITE_LOCKED) when a competing
transaction holds the database lock for longer than the driver's busy
timeout, and the persist layer surfaced those failures immediately.
withSerializableTx, the single choke point every write flows through,
now retries the whole begin-execute-commit cycle with exponential
backoff for transient errors, while permanent errors still surface on
the first attempt. Transient detection unwraps the error chain and
matches the driver's typed busy/locked codes, so SDKError-wrapped
failures are recognized.

The previously unused SPIKE_NEXUS_DB_OPERATION_TIMEOUT (default 15s,
already documented in the configuration table) now bounds the DB path
as a context deadline: it caps the write retry window and applies to
the four read entry points (LoadPolicy, LoadAllPolicies, LoadSecret,
LoadAllSecrets). Reads keep relying on WAL mode and the busy_timeout
DSN parameter for lock handling.

Unit tests cover transient detection through wrapped chains,
retry-then-succeed, permanent-error-no-retry, and deadline bounding.

Spec: TBD
Signed-off-by: Volkan Özçelik <volkan.ozcelik@broadcom.com>
File two follow-ups discovered during this week's work: the Pilot
prints normal output to stderr (cobra's Print family defaults to
OutOrStderr and the root command never calls SetOut, so
`spike secret get x > file.txt` yields an empty file), and the sqlite
state tests use the real ~/.spike/data/spike.db, deleting the live dev
environment's database whenever `make test` runs alongside it.

Close the Bootstrap keeper-wait task as stale: the SDK retry migration
already bounded every keeper interaction (retry.WithMaxAttempts with a
per-keeper context timeout and configurable backoff in
app/bootstrap/internal/net/dispatch.go; WithMaxElapsedTime bounds init
verification in broadcast.go).

Annotate the env-accessor task: the log.FatalLn-calling accessors now
live in spike-sdk-go config/env, so the sentinel-error refactor is an
upstream SDK change, and the in-repo share is adapting callers once the
SDK ships it.

Close the sqlite retry task and the DatabaseOperationTimeoutVal wiring
task, both delivered by the previous commit.

Spec: TBD
Signed-off-by: Volkan Özçelik <volkan.ozcelik@broadcom.com>
@v0lkan v0lkan self-assigned this Jul 17, 2026
@v0lkan
v0lkan merged commit 6c36860 into main Jul 17, 2026
14 checks passed
@v0lkan
v0lkan deleted the fix/sqlite-resilience branch July 17, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant