Commit Graph
73 Commits
Author SHA1 Message Date
ldm0 4c51eab400 refactor(indexeddb): remove legacy schema state adapters
Use typed metadata as the only store name source. Remove retired metadata
slots, descriptor projection, swallowed writes and the mutable index marker;
classify cursor sources by their native wrapper kind.

Make queue scope types explicit, exercise StoreId in admission tests, and
centralize renderer metadata lookup by schema ID. Retain failed schema
handle attributes and immutable metadata needed for rollback.
2026-11-13 01:39:46 +08:00
ldm0 b8190ee87d refactor(indexeddb): address SQL schema by stable IDs
Use the persisted StoreId and IndexId in SQL commands, transaction scopes and renderer handles. Reserve IDs without waiting for the SQL owner and recover their counters with committed disk metadata.

Remove name-based request targets, separate renderer identity tokens and cursor name refresh. Cover concurrent reservations, abort, idle reconnect, catalog recovery, restart, stale IDs and old-name reuse.
2026-11-13 01:39:46 +08:00
ldm0 f5504ff404 test(indexeddb): keep held database barriers under guard control
Release synthetic blocking work only when its guard is dropped, including during unwinding. Exercise real maintenance timers with flat SQLite files so unrelated catalog publication does not consume the observation window, and assert that the held owner remains live.
2026-11-07 10:55:09 +08:00
ldm0 db58d0fd7a test(indexeddb): wait for crash setup progress
Report completed preparation stages to the parent and apply the existing ten-second inactivity watchdog between them. Retain forced termination and reaping while avoiding an aggregate budget for process startup and durable filesystem setup.
2026-11-07 10:55:09 +08:00
ldm0 d2ca9ed387 test(indexeddb): isolate idle maintenance timer observations
The Windows persistence test compared a lifetime maintenance submission
counter with one. Startup maintenance could already have completed before
the database hold was established, so an old completed check plus one
pending check failed the assertion even with correct owner deduplication.

Stop the startup maintenance producer and drain the owner's FIFO through
the hold before recording a baseline and starting the observed timer.
Keep the exact one-new-check assertion and later-round reclamation of a
database created after the blocked round.

Add a case with a completed check before blocking to exercise nonzero
startup history deterministically, using the existing timer and budgets.
2026-11-03 19:09:44 +08:00
ldm0 244192dccb refactor(storage): remove unused cross-partition usage APIs 2026-11-01 05:19:55 +08:00
ldm0 ef1f983b4b refactor(storage): share the partition SQLite runtime with IndexedDB 2026-11-01 04:03:38 +08:00
ldm0 fceead4264 test(indexeddb): release registry before connection probes
Snapshot database clients before waiting for owner callbacks. Holding the
registry guard across those waits can block maintenance on the single SQL
scheduler, preventing the callbacks from running.

Add a forced maintenance-overlap regression for the connection inventory;
retain the existing timeouts and physical-connection assertions.
2026-10-31 17:07:52 +08:00
ldm0 34426cfacb fix(indexeddb): wait for Blob preservation during owner shutdown
Defer rejected Blob read completions until the owner's existing close
receipt. Resolve the saved bytes or preservation error on a blocking
worker so sealing a mailbox cannot expose a transient Closed error.

Cover Bucket clear, Service shutdown, preservation failures and reads
queued after database deletion with deterministic barriers.
2026-10-30 20:27:08 +08:00
ldm0 bd16444c7b ci: cover SQLite persistence and catalog recovery on Windows
Exercise native SQLite and IndexedDB directly in Windows persistent-storage CI, including doctests and complete-suite failure reporting. Normalize the catalog fixture root to the canonical Windows path.
2026-10-30 20:27:08 +08:00
ldm0 a587a5ecee perf(indexeddb): load Blob bodies on demand across consumers
Return immutable stored Blob/File sources without eagerly reading their bodies. Keep metadata, clone and slice lazy; route consumption through the owner, stream in chunks, and preserve handed-out data before destructive changes or retirement.

Adapt FileReader, Clipboard, WebSocket and OPFS together with the source representation. Share Fetch/XHR object-body extraction and propagate Blob and multipart read failures instead of string coercion. Preserve cancellation, ordering, backpressure, quota, permission/error semantics and realm cleanup across consumers.
2026-10-30 20:27:08 +08:00
ldm0 f802862181 refactor(indexeddb): use Tokio database owners and timed connection cleanup
Replace fixed worker shards and Lane locks with one async worker and one FIFO owner per database. Move synchronous SQL, connection work and catalog operations to the blocking pool. Drain accepted work and await final owner receipts before retirement or runtime teardown.

Use a single maintenance task with a short idle grace and at most one pending check per database, so slow owners cannot stall later rounds. Retry transient open failures in the same prepared generation while preserving terminal missing-file checks. Cover lifecycle races, low-FD creation and recovery, and single-worker host shutdown without new shared resource budgets.
2026-10-30 20:27:08 +08:00
ldm0 c68f23b8d2 perf(indexeddb): deliver getAll results in internal batches
Seek through bounded native result pages while preserving one JavaScript result and request FIFO. Cover key-only reads, index ordering, large values, and cancellation.

Validation: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
2026-10-30 20:27:08 +08:00
ldm0 b52ca510ea fix(indexeddb): preserve UTF-16 schema names through SQLite
Carry store and index names as IndexedDbName code units through WebIDL DOMString16 conversion, transaction scopes/admission, metadata, queued operations, cursors and DOMStringList. Store labels as ordered UTF-16BE BLOBs in SQLite schema v3; migrate known v1/v2 tables transactionally while preserving stable ids, records, indexes, generators and logical usage. Reuse the database-name codec and existing SQL command FIFO. Add exact surrogate/replacement/NUL/astral name operations in Window, iframe and Worker, plus native disk restart and malformed-label migration rollback/retry tests. This prerequisite supplies the lossless name model needed by the separate index/store rename setters.
2026-10-30 17:50:36 +08:00
ldm0 8564d0a23f fix(indexeddb): preserve UTF-16 database name identity
Preserve database DOMString names as IndexedDbName code units across derived WebIDL conversion, native connection FIFO, SQL service identity, IDBDatabase.name and databases() results. Store database names as UTF-16BE BLOBs in SQLite schema v2. Migrate v1 TEXT metadata inside one SQL transaction after owner/name/generation validation, keeping records, stable ids, generators and logical quota accounting. Extend the existing generation-path hash with canonical WTF-8 so legacy Unicode directory paths remain unchanged. Retain the complete original Window/iframe/Worker conversion, independent-record/version, abort, deletion and cross-agent matrix. Add real disk-profile restart plus legacy migration/failure, exact queue identity, path compatibility and quota-rollback regressions. This database-name topic is independent of object-store/index rename and readonly schema attributes.
2026-10-30 17:50:36 +08:00
ldm0 53fd3f6fd8 feat(indexeddb): add transactional SQLite schema renames
Add native SQL-owner commands for object-store and index renaming during a versionchange transaction. Resolve accepted names after preceding CREATE commands on the existing FIFO, then update only the stable store/index id label; records, index entries and key generators retain their identities. Keep name usage accounting inside the request SAVEPOINT, preserve committed snapshots until COMMIT, and let SQLite roll back aborts and quota failures. Cover duplicate and missing names, no-op/empty names, name reuse, queued create/write/rename ordering without an id round trip, and a real disk catalog restart. This is a direct-main prerequisite for the separate Web API rename work; store/index names retain the existing native TEXT model in this PR.
2026-10-30 17:50:36 +08:00
ldm0 b915eee210 fix(storage): handle long Windows catalog paths without hanging tests 2026-10-30 04:40:18 +08:00
ldm0 961afd5c56 refactor(indexeddb): remove unused transaction scheduler modes 2026-10-30 03:31:32 +08:00
ldm0 273ce0519d refactor(indexeddb): remove shared in-flight memory budgets 2026-10-30 03:31:32 +08:00
ldm0 d8755b9ff9 refactor(indexeddb): replace task tickets with one data byte budget 2026-10-30 03:31:32 +08:00
ldm0 c39e57481e refactor(indexeddb): remove metadata budgets and allocation leases 2026-10-30 03:31:32 +08:00
ldm0 7f96bc9280 refactor(indexeddb): remove registration and admission queue limits 2026-10-30 03:31:32 +08:00
ldm0 b140cd328f refactor(indexeddb): remove residual renderer compatibility paths 2026-10-30 03:31:32 +08:00
ldm0 1e12dbd313 refactor(indexeddb): drop legacy JSON key encoding 2026-10-30 03:31:32 +08:00
ldm0 426c044578 fix(indexeddb): retire live SQL owners after worker failure 2026-10-30 03:31:32 +08:00
ldm0 29bc89071c refactor(indexeddb): require SQL metadata budgets and refresh benchmarks 2026-10-30 03:31:32 +08:00
ldm0 9f6f909c6f fix(indexeddb): admit concurrent readers by object-store scope 2026-10-30 03:31:32 +08:00
ldm0 c8a04cbc6f fix(indexeddb): backpressure SQL execution without retaining slots 2026-10-30 03:31:32 +08:00
ldm0 26a50c0116 refactor(indexeddb): remove JSON backend and whole-database working copies
Keep IndexedDbManager as the owner of a required SQLite service, with committed usage and shutdown access. Remove the synchronous storage API, legacy persistence and transaction data copies.

Delete bucket IDB owner-key imports while preserving durable bucket identities, pending deletion and CacheStorage recovery. Port storage fixtures and the native benchmark to actual SQL connections and commands; retain generic key/direction tests and port cold-reopen and invalid-key transaction contracts to SQLite.

Validation: cargo fmt --all; workspace Clippy with all targets/features and -D warnings; nextest 21,815 passed,19 skipped;229 native/storage tests passed all20 stress iterations;memory/disk benchmark smoke passed.
2026-10-30 03:31:32 +08:00
ldm0 6a1b3240ae refactor(indexeddb): use native SQL connection lifecycle throughout renderer
Remove synchronous factory and transaction lifecycle fallbacks and the legacy blocked-open coordinator. Require SQL clients when creating database wrappers and refresh metadata directly from the committed snapshot.

Route exact Window and popup retirement to native SQL connections through weak references. Closing a shared-realm popup now releases its upgrade blockers without closing the opener or retaining collected wrappers.

Validation: cargo fmt --all; workspace Clippy with all targets/features and -D warnings; nextest 21,858 passed, 19 skipped; 495 related tests passed all 20 stress iterations. Preserved independent protocol baseline failures in local evidence.
2026-10-30 03:31:32 +08:00
ldm0 068941f411 refactor(indexeddb): use SQLite across renderer storage entry points
Route the public manager constructor through the SQLite service, including protocol ephemeral browser contexts. Match injected bucket owners and run existing storage fixtures through native completions and the Page task dispatcher.
2026-10-30 03:31:32 +08:00
ldm0 620ce7735f feat(indexeddb): enable SQLite for browser partitions 2026-10-30 03:31:32 +08:00
ldm0 3aceb8a3e2 fix(indexeddb): close partition SQL before releasing profile locks 2026-10-30 03:31:32 +08:00
ldm0 24af92a4ac feat(indexeddb): complete bucket deletion on storage workers
Reserve bounded cleanup work before dispatch, serialize duplicate tombstones under the existing quota coordinator, and resolve the accepting Page or Worker promise after SQLite and OPFS cleanup. Keep accepted deletion alive after Page retirement and protect same-name replacement buckets with their exact identity.
2026-10-30 03:31:32 +08:00
ldm0 bda47c16f6 fix(indexeddb): preserve close ordering and inline abort events
Publish native connection closure after notification unregistration so versionchange checkpoints cannot latch a stale blocked event. Route rejected inline cancellation through rollback and abort delivery for live owners, keeping request errors before transaction aborts.
2026-10-30 03:31:32 +08:00
ldm0 e26389031c feat(indexeddb): add fenced owner cleanup on SQL workers
Reserve bounded cleanup metadata and one control slot before fencing an owner. Close each database on its SQL lane, retire generation directories, cancel accepted factory requests and only then allow a new generation. Return logical connection retirement capacity at the native close receipt even when callers retain closed wrappers.
2026-10-30 03:31:32 +08:00
ldm0 2fd7e9325e feat(indexeddb): enforce bucket quota in SQLite transactions
Check request SAVEPOINTs and COMMIT against committed bucket usage shared with CacheStorage and OPFS. Acquire quota on the storage worker, retain reservations through publication, and finish rejected deferred submissions only after native rollback confirmation.
2026-10-30 03:31:32 +08:00
ldm0 26b225b5f2 fix(indexeddb): remove per-worker SQLite connection limit 2026-10-30 03:31:32 +08:00
ldm0 3b74cb177c test(indexeddb): cover WebIDL version limits and persistence
Cover maximum exact WebIDL versions through native transaction rollback,
regular writes, catalog recovery and real factory events and reopens.
Assert synchronous rejection above 2^53-1 and preserve the native overflow
guard, original generation and stored records.
2026-10-30 03:31:32 +08:00
ldm0 c11e0220b3 feat(indexeddb): route web factory requests through SQLite owners
Resolve open/delete through the native connection FIFO and owner completion
tasks. Bind actual Page/Worker database lifetimes to native connections and
retain request leases through their event microtask checkpoint.

Separate the worker-owning Service from clonable ServiceClient handles. Wake
all factory requests on shutdown, and wait for an in-flight close receipt
before acknowledging versionchange to avoid spurious blocked events.

Roll back failed or interrupted upgrades before following opens proceed,
preserve explicit COMMIT, and cover real web APIs, Worker retirement, disk
restart, legacy-directory isolation and native shutdown failures.
2026-10-30 03:31:32 +08:00
ldm0 7f2d010be2 feat(indexeddb): coordinate SQL connection lifetime and upgrade notifications 2026-10-30 03:31:32 +08:00
ldm0 cd03f84fcd feat(indexeddb): resolve SQLite catalog names and recover generations 2026-10-30 03:31:32 +08:00
ldm0 55973f5a66 feat(indexeddb): budget derived index keys before allocation
Share schema snapshots in SQL writes and charge key buffers, multiEntry deduplication, and output capacity to their existing task permit. Refund failed conversions and temporary traversal state while preserving ordinary getter exceptions and inline-key rollback semantics.
2026-10-30 03:31:32 +08:00
ldm0 6793d2460a feat(indexeddb): bound renderer schema metadata retention
Lease shared map, store and index definitions from the native metadata budget and release database mirrors with their wrappers. Preserve FIFO schema failure events, roll back failed materialization, and promote successful SQL upgrades without allocating a new mirror.
2026-10-30 03:31:32 +08:00
ldm0 c5d3ae598a feat(indexeddb): bound retained database registration memory 2026-10-30 03:31:32 +08:00
ldm0 e56cd437d7 feat(indexeddb): share and bound native schema snapshots 2026-10-30 03:31:32 +08:00
ldm0 34474667fb fix(indexeddb): abort frontend transactions when SQL ownership is lost 2026-10-30 03:31:32 +08:00
ldm0 1010d92074 fix(indexeddb): preserve SQL transaction identity and rollback failed commits 2026-10-30 03:31:32 +08:00
ldm0 9760230e7f refactor(indexeddb): share retained payload size accounting 2026-10-30 03:31:32 +08:00
ldm0 f4a33b25da fix(indexeddb): grow query result reservations before allocation 2026-10-30 03:31:32 +08:00