Skip to content

Add atomic transaction API#28

Open
findolor wants to merge 1 commit into
mainfrom
transaction-api
Open

Add atomic transaction API#28
findolor wants to merge 1 commit into
mainfrom
transaction-api

Conversation

@findolor

@findolor findolor commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Dependent PRs

Motivation

Consumers that pass SQLiteWasmDatabase.query.bind(localDb) into SDK transaction batches currently express logical transactions as separate query() calls: BEGIN TRANSACTION, individual statements, then COMMIT. sqlite-web serializes individual worker messages, but it does not hold a transaction-level lock across multiple query() calls. With multiple handles/tabs sharing a database, those split transaction calls can interleave and SQLite can return cannot start a transaction within a transaction.

Solution

  • Add public SQLiteWasmDatabase.transaction(statements) JS API that accepts { sql, params? }[].
  • Send the whole statement list as one worker job through the coordinator and DB worker queue.
  • Execute the batch inside a worker-owned SQLite transaction, returning the last statement result and rolling back on failure.
  • Reject user-supplied transaction-control statements (BEGIN, COMMIT, END, ROLLBACK, SAVEPOINT, RELEASE) so the worker owns transaction scope.
  • Add browser integration coverage that verifies successful transaction execution, rollback, and the old split-BEGIN interleaving failure.
  • Retry OPFS sahpool deletion after worker termination so wipeAndRecreate handles Chrome briefly retaining OPFS handles.
  • Update the rain.math.float submodule and dependency graph for the latest float crate.
  • Update Rainix so CI uses a Rust toolchain new enough for revm 36.
  • Install the float submodule Soldeer dependencies in build-submodules before running forge build.
  • Fix the local bundle script to rewrite the current wasm-bindgen export form for embedded classic workers.

Checks

By submitting this for review, I am confirming I have done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Validation run:

  • cargo fmt --all
  • cargo check --tests -p sqlite-web-core
  • cargo check --tests -p sqlite-web
  • ./scripts/local-bundle.sh
  • bun run test (158 passed | 4 skipped)
  • npm run lint-format-check in svelte-test
  • nix develop -c rustc --version (rustc 1.94.0)
  • nix develop -c build-submodules
  • nix develop -c local-bundle
  • Manual NO_HEADLESS wasm browser test for sqlite-web-core (98 passed; 0 failed)
  • Manual NO_HEADLESS wasm browser test for sqlite-web (38 passed; 0 failed before OPFS retry; CI rerun pending)
  • git diff --check

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@findolor, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 40 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7d216f8f-9a74-49d2-8525-1117e13071f8

📥 Commits

Reviewing files that changed from the base of the PR and between a4d6dbe and 0f66c72.

⛔ Files ignored due to path filters (4)
  • Cargo.lock is excluded by !**/*.lock
  • flake.lock is excluded by !**/*.lock
  • svelte-test/bun.lock is excluded by !**/*.lock
  • svelte-test/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • Cargo.toml
  • flake.nix
  • lib/rain.math.float
  • packages/sqlite-web-core/src/coordination.rs
  • packages/sqlite-web-core/src/database.rs
  • packages/sqlite-web-core/src/messages.rs
  • packages/sqlite-web/src/db.rs
  • scripts/local-bundle.sh
  • svelte-test/package.json
  • svelte-test/tests/integration/transaction-interleaving.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch transaction-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@findolor findolor self-assigned this Jun 26, 2026
@findolor findolor force-pushed the transaction-api branch 4 times, most recently from 1653cc5 to c959ab8 Compare June 26, 2026 11:07
@findolor findolor requested review from 0xgleb and JuaniRios June 26, 2026 11:21
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.

1 participant