Skip to content

Commit 0e7a7ed

Browse files
committed
[miniflare] Add storage-owner tests and high-concurrency oracle
Unit tests for owner election, presence, routing and teardown, plus a high -concurrency oracle that runs multiple instances against one persist root and asserts KV/R2/D1/Streams/Secrets/Images sharing with exactly-correct results under contention. The oracle runs under MINIFLARE_TEST_SHARED_OWNER (added to turbo.json globalPassThroughEnv) so it gates both feature-on and baseline modes.
1 parent 1280304 commit 0e7a7ed

4 files changed

Lines changed: 3389 additions & 0 deletions

File tree

.changeset/shared-storage-owner.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"miniflare": minor
3+
---
4+
5+
Add experimental `unsafeSharedStorageOwner` option to share local storage across processes
6+
7+
When several Miniflare instances run against the same persist root (for example multiple `wrangler dev` / `vite dev` sessions), each one opens the same SQLite and blob files, which can produce cross-process `SQLITE_BUSY` errors under concurrent access. With `unsafeSharedStorageOwner` enabled, a single detached "owner" process opens the storage files and every other instance routes its KV, R2, D1, Images, Streams and Secrets Store operations to that owner over the remote-bindings boundary, so exactly one process performs storage I/O. The owner is elected and spawned automatically, publishes its address to the persist root, and self-terminates once no instances remain.
8+
9+
The option is off by default. Cache, Durable Objects and Workflows are intentionally kept per-instance rather than routed, so processes never contend on those databases.

0 commit comments

Comments
 (0)