Skip to content

The queue drain has a caller now, and it is the host's - #156

Merged
wenjianzhang merged 1 commit into
mainfrom
docs/queue-drain-has-a-caller
Sep 8, 2026
Merged

wenjianzhang merged 1 commit into
mainfrom
docs/queue-drain-has-a-caller

Conversation

@wenjianzhang

Copy link
Copy Markdown
Member

Two statements in the documentation stopped being true when go-admin#918 landed, and both are the kind that sends a reader somewhere unhelpful.

known-issues.md entry 2 said the messages buffered at SIGTERM are still lost. v2.7.0 fixed the drain itself, and that entry correctly recorded that nothing was calling it — go-admin shut down only the previous adapter during a reload, and abandoned the installed one at exit. go-admin now registers a BeforeExit callback for it. A reader following the old text would either build something that already exists, or plan around a data-loss risk that is no longer there.

contract.md section 12 said a deployment that cannot lose audit rows has to register that shutdown itself. Also no longer true of go-admin, and the sentence left a host writing its own wiring with nothing to go on.

The replacement says what to do, and names the trap that made the go-admin implementation harder than it looks: shut down the adapter the host installed, not whatever GetQueueAdapter returns. That accessor never returns nil — with no queue section configured the runtime wraps its own fallback — so going through it closes a queue the host neither built nor started, while looking like it worked.

What has not changed is where the call comes from. This module provides the drain and has no point at which it could notice a host that never asks for it. A host that registers nothing still loses its backlog, silently, and both files now say that rather than implying the problem is gone.

Documentation only.

known-issues.md said the messages buffered at SIGTERM are still lost.
That was true when it was written and stopped being true with
go-admin-team/go-admin#918, which registers a BeforeExit callback that
shuts down the adapter go-admin installed. A reader following the old
text would either rebuild something that already exists, or route around
a data-loss risk that is no longer there.

contract.md section 12 said a deployment that cannot lose audit rows has
to register the shutdown itself. Also no longer true of go-admin, and
the sentence gave a host writing its own wiring no idea what to write.
It now says what to do and names the trap: shut down the adapter the
host installed, not whatever GetQueueAdapter returns - that accessor
never returns nil, and with nothing configured it wraps this module's
own fallback queue, so going through it closes a queue the host neither
built nor started.

What has not changed is where the call comes from. This module provides
the drain and cannot notice a host that never asks for it; a host that
registers nothing still loses its backlog, silently. Both files say so.
Copilot AI lite review requested due to automatic review settings September 8, 2026 02:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

Documentation-only changes appear internally consistent with core’s runtime behavior (notably GetQueueAdapter/fallback semantics) and align with the PR description’s intent.

Pull request overview

Updates documentation to reflect that queue draining on shutdown is provided by go-admin-core but must be invoked by the host, and that go-admin now registers the appropriate BeforeExit callback (per go-admin#918). This clarifies the remaining risk for other hosts and calls out the subtle trap of shutting down the wrong queue instance.

Changes:

  • Update known-issues.md to explain that go-admin now calls the drain on exit, while other hosts must still wire it themselves.
  • Update contract section 12 to state the host’s responsibility for registering the shutdown callback, including guidance to shut down the installed adapter (not the GetQueueAdapter wrapper/fallback).
File summaries
File Description
docs/known-issues.md Corrects the shutdown/drain “caller” status and clarifies remaining host responsibility.
docs/contract.md Updates lifecycle contract text with accurate host wiring guidance and the GetQueueAdapter shutdown trap.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@wenjianzhang
wenjianzhang merged commit 90d8480 into main Sep 8, 2026
6 checks passed
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.

2 participants