You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add re-entrance guard to prevent concurrent coroutine access
DqliteConnection now detects when two coroutines attempt to use the
same connection concurrently and raises InterfaceError immediately,
matching the behavior of asyncpg and other mature async DB clients.
The dqlite wire protocol is strictly request-response with no
pipelining. Without this guard, concurrent coroutines would interleave
their sends and reads on the shared StreamWriter/StreamReader, causing
response mix-ups, ProtocolErrors, or silent data corruption.
Each public method (execute, fetch, fetchall, fetchval) sets an
_in_use flag before the protocol operation and clears it after. If
a second coroutine tries to use the connection while _in_use is True,
InterfaceError is raised with a clear message directing users to use
ConnectionPool for concurrent operations.
Also adds InterfaceError to the exceptions module and public API.
Closes #077
Also resolves #079 (_in_transaction flag race) and #084 (concurrent
connect TOCTOU) since the guard prevents concurrent access entirely.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments