Repository navigation
Engine: database work runs in order on one thread - #1282
Merged
Merged
Conversation
vmillet-dev
force-pushed
the
engine/db-queue
branch
from
November 2, 2026 21:47
b2b99dd to
9c9ae94
Compare
This was referenced Nov 2, 2026
vmillet-dev
force-pushed
the
engine/db-queue
branch
from
November 2, 2026 22:07
9c9ae94 to
fedebab
Compare
This was referenced Nov 2, 2026
A send reads, sends, then writes only into the library it read from. Sends and sockets run on the runtime the shell passes to the engine.
vmillet-dev
force-pushed
the
engine/db-queue
branch
from
November 2, 2026 22:32
fedebab to
6e34b36
Compare
This was referenced Nov 2, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #1279 (#1146) and #1281 (#1147): until they merge, this diff shows their commits too.
Phase 1, step 3 of
docs/egui-migration-plan.md(§ 3.3.6, D11, D18, D30).db/queue.rs): one thread, owned by theEngine, runs its jobs in the order they arrive.db::blocking(andblocking_on, for async code holding the engine) drops the body there instead of on Tokio's blocking pool. Two writes sent one after the other now land in that order.catch_unwind) and answersStorageUnavailable; the queue goes on. A poisonedMutexkeeps answeringUnavailable, as today.db::lockasserts in debug builds that it runs on the db thread. The crate's own unit tests lock their in-memory libraries on the test thread and are exempt (cfg!(test)); the integration tests and the e2e build (a debug build) are not.Librarygets one from a process counter when it is opened (Library::number, never 0). A send notes it at its read step (prepare), and its write steps — the variables the scripts wrote, then history and cookies — go throughdb::lock_library: another library open since, nothing is written, and the log says so. Writes still merge (cookies replayed as changes, variables re-read before applying).Engine::newtakes the shell's Tokio handle (tauri::async_runtime::handle()); sends, sockets and the flight's blocking work run on it instead oftauri::async_runtime. The tools'off_threadandexplore_jsonkeep Tauri's until Engine: each command becomes a service function #1149 moves their wrappers to the shell.architecture.md→ « Persistence (Rust) » (one thread, in order; a send in three steps),CLAUDE.md.Tests (§ 3.3.6,
tests/commands/concurrency.rsanddb/queue.rs):update_notesent at once on the same note: the second wins;lock()off the db thread panics in debug.Local:
cargo fmt --all --check,cargo clippy --workspace --lib --bins --tests --benches --all-features -D warnings,cargo test --workspace --lib --bins --testsgreen. No local e2e (the machine is in use): CI runs the 35 scenarios on the debug e2e build, which also exercises the thread assertion.🤖 Generated with Claude Code