Skip to content

feat: weblock controlled opfs pool - #24740

Merged
mverzilli merged 7 commits into
merge-train/fairies-v5from
martin/sqlite-web-lock
Jul 17, 2026
Merged

feat: weblock controlled opfs pool#24740
mverzilli merged 7 commits into
merge-train/fairies-v5from
martin/sqlite-web-lock

Conversation

@mverzilli

@mverzilli mverzilli commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Prevents multi-tab concurrency issues in SQLite store creation by guarding it with weblocks.

Closes F-829

@mverzilli
mverzilli requested a review from Thunkar July 15, 2026 21:31

@Thunkar Thunkar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, and the error is much more descriptive!

@mverzilli
mverzilli requested a review from a team as a code owner July 16, 2026 07:55
Base automatically changed from gj/sqlite_corruption_escape to merge-train/fairies-v5 July 16, 2026 08:10
@mverzilli
mverzilli merged commit 386f120 into merge-train/fairies-v5 Jul 17, 2026
15 checks passed
@mverzilli
mverzilli deleted the martin/sqlite-web-lock branch July 17, 2026 14:48
mverzilli added a commit that referenced this pull request Jul 17, 2026
This is a defensive measure in case more than one SQLite page file is
found pointing to the same logical name, which could cause undefined
behavior. This could happen with old, pre-weblock controlled versions of
wallet/pxe (see
#24740), so it's
unlikely to be found in the wild, but it gives us graceful coverage if
that happens.

We detect if a pool contains two valid .opaque files mapped to the same
logical SQLite path, then:

  1. Acquire the pool Web Lock.
2. Copy the entire pool byte-for-byte into:
.aztec-sqlite-quarantine/<timestamp-random>/
  3. Verify the copied directory and file contents.
  4. Write a quarantine.json describing the duplicate mappings.
  5. Delete the original active pool.
  6. Open a new, empty database under the original pool name.
  7. Emit a warning log containing the quarantine location.

The caller receives a successfully opened but empty store, so wallet/PXE
state would need to be recreated or resynchronized. The quarantined
bytes remain available for forensic or manual recovery, although there
is currently no public API or UI for that.

If copying or verification fails, opening fails and the original pool is
not intentionally removed. If the pool merely comes from an old version
but has no duplicate logical mappings, nothing special happens, it opens
normally.

---------

Co-authored-by: Gregorio Juliana <gregojquiros@gmail.com>
@PhilWindle PhilWindle added port-to-next Forward-port this merged PR into next and removed port-to-next Forward-port this merged PR into next labels Jul 21, 2026
mverzilli added a commit that referenced this pull request Jul 23, 2026
Forward port the following PRs from v5-next to next:

- #24631
- #24647
- #24739
- #24740
 - #24743

---------

Co-authored-by: Gregorio Juliana <gregojquiros@gmail.com>
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.

3 participants