fix(store): checkpoint the WAL on the store's own keyed connection #54
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/store-checkpoint-wal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Node::shutdown()/Node::flush()promise a WAL checkpoint, but on the SQLCipher store (PR #43) that checkpoint ran through a short-lived second connection with no key, so it degenerated to:Nothing was lost (sqlite folds the WAL in when the last connection closes), but the explicit truncation never happened on a real store.
What
src/store.rs— newStore::checkpoint_wal()runsPRAGMA wal_checkpoint(TRUNCATE)on the connectionStoreowns (the keyed one).wipe_messagesreuses it instead of its inline copy.src/node.rs—Node::checkpoint()locks the node'sArc<Mutex<Store>>and calls it. The second-connection helper and its "encrypted store is skipped" doc caveat are deleted.Node::shutdown()/Node::flush()public signatures unchanged.src/store.rs::at_rest::checkpoint_wal_truncates_an_encrypted_store_wal: it writes 64 rows throughStore::open_at_with_passphrase, then assertsonionwire.db-walis 0 bytes aftercheckpoint_wal(). The live test (tests/tor_lifecycle.rs, ignored) now also asserts the WAL is non-empty beforeflush()and 0 bytes after, on a bootstrapped node. Thenode.rs::lifecycle_testsmodule goes away: with the helper gone nothing in it runs without a live node, and "no store at all" is no longer a state aNodecan be in (startalways opens/creates the store).RED first, on the current implementation, against a real encrypted store:
Evidence
cargo test --locked— 28 suites, 216 passed, 0 failed, 4 ignored. (216 not 217: two offline tests innode.rswere deleted, one store-level test added;store::at_rest::checkpoint_wal_truncates_an_encrypted_store_wal ... ok.)cargo clippy --locked --all-targets -- -D warnings— exit 0.cargo test --locked --test tor_lifecycle -- --ignored --nocapture→test shutdown_stops_the_node_and_later_calls_are_typed_errors ... ok(1 passed, 135.9s), including the new WAL assertions.Stacking
Based on
feat/tor-lifecycle@48c06df(PR #49) — the second-connection helper this card deletes only exists there, not onmain, so amain-based branch could not deliver item 2 of the card. Retarget this PR tomainonce #49 lands; the diff is then exactly the 3 files above.Wire frames / protocol untouched, no
docs/PROTOCOL.mdchange.