diff --git a/changelog/2026-06-10-msg-secret-semaphore.mdx b/changelog/2026-06-10-msg-secret-semaphore.mdx new file mode 100644 index 00000000..13fdfd74 --- /dev/null +++ b/changelog/2026-06-10-msg-secret-semaphore.mdx @@ -0,0 +1,20 @@ +--- +title: "June 10, 2026 — Fix: msg_secret reads serialized through db semaphore" +description: "get_msg_secret and get_msg_secret_with_ts now route through with_semaphore, preventing silent decryption failures on in-memory stores when a read races a write." +--- + +## Bug fixes + +**SQLite store: serialize `msg_secret` reads through the db semaphore ([#832](https://github.com/oxidezap/whatsapp-rust/pull/832))** + +`get_msg_secret` and `get_msg_secret_with_ts` were dispatched via raw `spawn_blocking`, bypassing the single-permit `db_semaphore` that all write paths (and most other reads) already acquire via `with_semaphore`. On in-memory (`:memory:`) stores a read that overlaps an active write transaction hits the shared-cache table lock and fails with `SQLITE_LOCKED` — an error not covered by `busy_timeout`. Both call sites treat a backend error as a lookup miss, so the failure was silent. + +In practice, the write-behind drain introduced in [#831](https://github.com/oxidezap/whatsapp-rust/pull/831) made this race consistently reachable: the detached batch write could race the very next incoming message's secret lookup. The symptom was encrypted reactions and channel comments (added in [#829](https://github.com/oxidezap/whatsapp-rust/pull/829)) arriving undecrypted, with no error logged. + +Both methods now go through `with_semaphore`. A read that arrives during a write waits for the permit instead of failing as a phantom miss. + +**Affected stores:** in-memory (`:memory:`) SQLite — used by the test suite and any embedded consumer. File-backed stores with WAL mode are not affected (WAL readers do not block on concurrent writers). + +## Breaking changes + +None. diff --git a/docs.json b/docs.json index 5b10c6c8..9df48095 100644 --- a/docs.json +++ b/docs.json @@ -138,6 +138,7 @@ "group": "Changelog", "pages": [ "changelog/overview", + "changelog/2026-06-10-msg-secret-semaphore", "changelog/2026-06-10-cag-enc-reactions-comments", "changelog/2026-06-10-hrtb-closures", "changelog/2026-06-10-server-aware-lookup-probe",