Repository navigation
storage: an agent-db not_found notice ends the connection for good - #8626
theomonnom wants to merge 1 commit into
Conversation
The server sends not_found on request id 0 when the database is deleted while the socket is open. It was read as a protocol error: the write in flight failed Disconnected (outcome unknown) and the next call redialed. As in the reference Go client, it is now a final notice: each request unanswered on that socket applied nothing and fails not found, every later call fails with it too, and the connection closes without a redial.
| st.fatal = Some(notice.clone()); | ||
| for pending in st.pending.values().filter(|p| p.socket == Some(generation)) { | ||
| if pending.answers.try_send(Answer::Frame(frame.clone())).is_err() { | ||
| log::trace!(target: lk_agents_abi::LOG_TARGET, "agentdb request dropped meanwhile"); | ||
| } | ||
| } |
There was a problem hiding this comment.
🟡 False refusal for other-socket writes
When another socket still holds an unanswered write, gone makes that write fail NotFound too. After closure, wait returns the connection-wide fatal error for its empty channel. The notice does not establish that other socket's write outcome, so a committed write can be reported as unapplied.
Learn more
A connection can retain an old socket with unanswered requests while using a replacement socket; Supervisor::run starts a separate reader for that old socket. A deletion notice guarantees that unanswered requests on its own socket applied nothing, but says nothing about requests on the other socket. Inner::close clears every pending request and cancels every reader. Requests on other generations receive no queued error here, so Conn::wait substitutes the connection-wide fatal error when their channels empty. The write-error conversion treats that NOT_FOUND as proof that nothing applied, losing the distinction between refusal and unknown outcome.
Example: Socket A commits an INSERT but has not delivered its answer. A different request receives wrong_shard_server, retiring A and opening socket B. B receives a deletion notice before A delivers its INSERT answer. Closing the connection makes the INSERT return NotFound, although only B's unanswered requests were proven unapplied.
Recommended fix: Before closing, queue a Disconnected terminal result for pending requests bound to other socket generations, while preserving already queued answers. Keep NOT_FOUND for the notifying generation and later unsent calls. Add a two-socket regression covering a retiring write whose answer remains outstanding when the replacement socket receives the deletion notice.
Was this helpful? React with 👍 or 👎 to provide feedback.
No description provided.