Skip to content

storage: an agent-db not_found notice ends the connection for good - #8626

Closed
theomonnom wants to merge 1 commit into
v2.0from
theo/agentdb-deleted-notice
Closed

theomonnom wants to merge 1 commit into
v2.0from
theo/agentdb-deleted-notice

Conversation

@theomonnom

Copy link
Copy Markdown
Member

No description provided.

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.
@theomonnom
theomonnom requested a review from a team as a code owner November 18, 2026 10:36
@theomonnom theomonnom closed this Nov 18, 2026
@theomonnom
theomonnom deleted the theo/agentdb-deleted-notice branch November 18, 2026 10:37

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment on lines +794 to +799
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");
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant