[DO NOT REVIEW] Added wal with shared cache #5785
Closed
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.
Summary
There seems to be a WAL race condition within the
builder.rsfile where a session is created and get session immediately after, which in some instances can fail because theread sessionis looking at an old version of the sessions db + WAL page from one thread before thewrite sessioncommit finishes propagating.I believe the culprit to be the lack of an explicit "commit" transaction with WAL enabled. In the concurrency section of sqlite documentation,
When a read operation begins on a WAL-mode database, it first remembers the location of the last valid commit record in the WAL. So even though we were relying on concurrency throughawait?;the commit never applied.This could also explain why the Pragma wal_checkpoint approach didn't work as the checkpoint didn't have a completed commit to apply WAL file changes to the database.
Type of Change
AI Assistance
Testing
I was unable to reproduce on multiple linux docker images, I went ahead and reproduced the "bug" (
create_sessionandget_sessionrace condition) by writing concurrent create_session -> get_session race condition tests and ran them a few thousand times.Related Issues
Relates to #5197
Discussion: