Skip to content

Commit 6d81ad8

Browse files
Prefix StmtResponse db_id-mismatch ProtocolError so SA disconnect classifier triggers
Cycle 21 added a defensive db_id-echo check in ``protocol.prepare()`` that raises ProtocolError on registry drift. The error text didn't match any of SA's ``_dqlite_disconnect_messages`` substrings, so SA's ``is_disconnect`` classifier missed it and the SA pool kept the broken slot. Prefix the message with the canonical "wire decode failed" phrase the SA classifier already recognises so a registry- drift event invalidates the slot, matching the cycle-21 commit's intent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 07ce597 commit 6d81ad8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/dqliteclient/protocol.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,17 @@ async def prepare(self, db_id: int, sql: str) -> tuple[int, int]:
345345
# connection is invalidated rather than silently routing
346346
# writes against the wrong DB.
347347
if response.db_id != db_id:
348+
# Prefix with the canonical "wire decode failed" phrase so
349+
# SA's ``is_disconnect`` substring matcher routes this
350+
# through the pool-invalidate path. Without the prefix,
351+
# the registry-drift event would surface as a non-
352+
# disconnect ProtocolError and the SA pool would keep the
353+
# broken slot. The prefix matches the wire-decode
354+
# invalidation already wired into
355+
# ``sqlalchemy-dqlite._dqlite_disconnect_messages``.
348356
raise ProtocolError(
349-
f"StmtResponse db_id {response.db_id} does not match "
350-
f"requested db_id {db_id}{self._addr_suffix()}"
357+
f"wire decode failed: StmtResponse db_id {response.db_id} "
358+
f"does not match requested db_id {db_id}{self._addr_suffix()}"
351359
)
352360

353361
return response.stmt_id, response.num_params

0 commit comments

Comments
 (0)