Repository navigation
cli/cmd/encore/daemon: open encore.db without the shared cache - #2631
Merged
jaglyserx merged 1 commit intoNov 11, 2026
Merged
Conversation
The daemon opened encore.db with cache=shared. In shared-cache mode SQLite fails a second writer, or a write to a table another connection is reading, at once with "database table is locked" instead of waiting. Apps upload a trace per request, so concurrent requests lost their traces: a test of 400 concurrent uploads stores about 250 of them. Without the shared cache each pooled connection waits up to the busy timeout for the write lock, and WAL keeps reads running alongside writes. All 400 uploads are stored. The open-and-migrate step moves into openEncoreDB so the test opens the database as the daemon does.
jaglyserx
approved these changes
Nov 10, 2026
jaglyserx
left a comment
Member
There was a problem hiding this comment.
Great PR, removing cache mode for SQLite seems natural as the feature is discouraged in modern usage most of the time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The daemon opens
encore.dbwithcache=shared. In shared-cache mode, SQLite does not wait for a lock held by another connection on the same cache. A second writer, or a write to a table another connection is reading, fails at once withdatabase table is locked.Apps upload a trace for every request, so requests that run at the same time write at the same time. The losing uploads fail, and the trace store logs the error and carries on. So under
encore run, the local dashboard silently misses traces whenever requests overlap, and nothing outside the daemon's log shows it.Fix
Drop
cache=sharedfrom the connection string. Each pooled connection then waits for the write lock, up to the driver's default busy timeout of 5 s, and WAL mode keeps reads running alongside writes.The open-and-migrate step moves into
openEncoreDB, so the test opens the database exactly as the daemon does.cache=shareddates from 2022, before WAL mode and immediate transactions were added.Other fixes I tried against the same test:
cache=shared(this PR)SetMaxOpenConns(1)database table is lockedImpact
TestEncoreDBStoresConcurrentTraceUploadsmakes 8 goroutines upload 50 traces each, the way concurrent requests do:cache=sharedTests
main(about 40% of spans lost) and passes with the fix.go test -short -tags=dev_build ./cli/cmd/encore/daemonpasses.Need help on this PR? Tag
@codesmith-botwith what you need.