死锁: 同步引擎在 await 中持有 blocking parking_lot:: Mutex; 并发的 connect()/push() 会在每个 tokio 工作进程中阻塞
作者: leshec创建于 2026年8月13日更新于 2026年9月16日
标签sync
- The coroutines built in
turso_sync_sdk_kit/src/rsapi.rsopen withsync_engine.lock_arc()— a blockingparking_lot::Mutex— and hold the guard across their.await, which for a push is the whole network round-trip. Six methods do this:connect(line 424),stats(447),checkpoint(464),push_changes(481),wait_changes(497),apply_changes(519). TursoDatabaseAsyncOperation::resume()drives agenawaiter::sync::Gen— a synchronous generator — so the coroutine body runs inline on whichever thread polls it (AsyncOpFuture::pollinturso/src/sync.rscallsresume()).- So a push takes the mutex, hits network IO, returns
Pending, and releases its thread with the mutex still held. Every other engine call then parks a tokio worker thread insidelock_arc(). Once all workers are parked, nobody is left to poll the push, its IO is never consumed, and the mutex is never released.
内容来源: tursodatabase/turso