Repository navigation
feat(chatd): add chat_wakeup_watches rows for events wake-ups - #339
Conversation
Adds a chatdmig node with one row per thing an events wake-up watches, and the forkdb queries that find the ready watches of the whole deployment in one statement. Nothing reads the table yet; the switch of chatd follows in a stacked change. Refs #293
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8def5b79ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… chats MarkChatWakeupWatchDelivered clears fired_at and fired_payload, so an open watch is not ready again for the event it just delivered. ListReadyChatWakeupWatches leaves out chats in error with queued messages, as ClaimDueChatWakeups does.
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged as 61fcbfd (squash, Gates on head 8a2a231, with main at 99ced87 (live on the server at merge time):
Tests I ran on this head:
Not exercised: nothing calls the new queries until #340, so there is no runtime behavior to test on a live server. |
Bottom of a stack for #293. The top PR switches chatd to these rows.
What changes
01a1df49-..._chat_wakeup_watches: enumchat_wakeup_watch_kind(child_done,process,pull_request) and tablechat_wakeup_watches, one row per thing an events wake-up watches. Columns follow the issue, plusordinal(delivery order inside the wake-up) andfailed_at(replaces the:failedrun keys that let the final poll retry a failed send).(wakeup_id) WHERE delivered_at IS NULL, and full indexes onchat_id,child_chat_idandorganization_idfor the cascades and lookups. The process and pull request partial indexes of the issue are left for chatd, agent: the agent reports process exits and matching output instead of chatd dialing it every 15 s #295 and chatd: one shared pull request poller with conditional requests, off the wake-up delivery path #296, which add their readers.InsertChatWakeupWatch,ListChatWakeupWatchesByWakeupID,ListChatWakeupWatchesByChatID,ListOpenChatWakeupWatchesByChatID,ListChildChatIDsWithOpenWakeupWatches,ListReadyChatWakeupWatches(the predicate of the issue, withchat_descendant_questions.answered_at IS NULLfrom chatd: descendant questions are polled every 2 s through a JSONB scan; store the answered state #300),MarkChatWakeupWatchDelivered(guarded bydelivered_at IS NULLand the expecteddeliveries),MarkChatWakeupWatchFailed.The table is additive: nothing reads or writes it until the top PR, so this PR deploys on its own.
Tests
TestListReadyChatWakeupWatches: 1 chat, 3 children, one wake-up watching them. Nothing while all run; exactly the finished child after one finishes; nothing while the parent isrunning; nothing for a child with an open watch of its own; nothing for a child with an unanswered question; an archived child is ready; a delivered watch delivers once; a paused wake-up delivers nothing.TestChatWakeupWatchRows: target checks, the cascade of a deleted child, output-line deliveries that keep a watch open, stale delivery counts,failed_at.TestListReadyChatWakeupWatchesPlan: 10,000 completed wake-ups (each with its own chat, a message and a delivered watch),ANALYZE, thenEXPLAINofListReadyChatWakeupWatches: noSeq Scanonchat_wakeups,chats,chat_messagesorchat_wakeup_watches.Ran:
go test ./coderd/database/dbauthz/ ./coderd/database/dbmetrics/ ./coderd/database/migrations/... ./coderd/database/forkdb/... -count=1(pass), the chatdmig tests withCHATDMIG_TEST_DATABASE_URL(pass),chatdmig check(pass),golangci-lint runon the changed packages (0 issues).