fix: Prevent issues with locks throughout the application #2351

Merged
Jade merged 11 commits from jade/deadlocks into main 2026-10-28 22:44:54 +00:00

2026-10-28

style: Format
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 10s
Checks / Prek / Check changed files (pull_request) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Successful in 1m41s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 21m42s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 7m56s
Checks / Prek / Check changed files (push) Successful in 5s
Checks / Prek / Pre-commit & Formatting (push) Successful in 1m12s
Release Docker Image / Build linux-amd64 (release) (push) Failing after 3m27s
Documentation / Build and Deploy Documentation (push) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (push) Has been cancelled
Release Docker Image / Build linux-arm64 (release) (push) Successful in 11m35s
Release Docker Image / Build linux-amd64 (max-perf) (push) Has been skipped
Release Docker Image / Create Multi-arch Release Manifest (push) Has been skipped
Release Docker Image / Build linux-arm64 (max-perf) (push) Has been skipped
Release Docker Image / Create Max-Perf Manifest (push) Has been skipped
Release Docker Image / Release Binaries (push) Has been skipped
Release Docker Image / Mirror Images (push) Has been skipped
2026-10-28 21:56:38 +00:00
chore: Changelog
Some checks failed
Checks / Prek / Check changed files (pull_request) Successful in 6s
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 10s
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 1m14s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
2026-10-28 21:49:26 +00:00
refactor(uiaa): Defer uiaa_sessions lock until session insert
Do not hold the uiaa_sessions lock across device lookup in OAuth or
during initial validation. Lock the map only when inserting the newly
created session.
2026-10-28 21:48:55 +00:00
refactor(service): Use SyncRwLock and SyncMutex for in-memory services
Convert in-memory data structures in appservice, rooms::typing, and sync
wakers to use SyncRwLock and SyncMutex. Drop appservice locks before
making outbound network requests in room alias queries and federation
invites.
2026-10-28 21:48:22 +00:00
refactor(metrics): Replace std::sync::Mutex with SyncMutex
Replace std::sync::Mutex with parking_lot::Mutex (SyncMutex) in
core::metrics::runtime_intervals. Note that info::introspection retains
std::sync::Mutex because parking_lot panics in dtor after thread locals
are destroyed.
2026-10-28 21:47:41 +00:00
refactor(threepid): Use SyncMutex and decouple guard from ValidSession
Change threepid sessions and send_attempts to SyncMutex and avoid

holding the sessions mutex across callers of get_valid_session.
2026-10-28 21:47:09 +00:00
refactor(oauth): Avoid holding pending grants lock across async calls
Convert pending grants and tickets to SyncMutex and scope locks tightly

before awaiting external calls in grant_info and redeem_token.
2026-10-28 21:46:29 +00:00
refactor(service): Scope services.manager lock during lifecycle calls
Avoid holding the services.manager lock across manager.start(),

manager.stop(), and manager.poll() async invocations.
2026-10-28 21:45:49 +00:00
refactor(admin): Release handle lock before command execution
Change admin service handle to SyncRwLock and copy the handler

function pointer before awaiting execution to prevent deadlock.
2026-10-28 21:45:18 +00:00
fix(main): Prevent re-entrant read lock deadlock during reload
Reuse the already-held main_lock when checking module staleness

in run() instead of re-acquiring server.mods.read().
2026-10-28 21:44:35 +00:00
fix(service): Prevent remote join lock inversion
Do not hold state.mutex across join_remote_room to prevent an ABBA

deadlock against mutex_federation.
2026-10-28 21:44:02 +00:00