Skip to content

fix(mcpx): bound sdnotify writes so abstract sockets cannot hang the suite (run 41819578987) - #8638

Closed
dezren39 wants to merge 1 commit into
mainfrom
queue/9439-sdnotify-timeout
Closed

dezren39 wants to merge 1 commit into
mainfrom
queue/9439-sdnotify-timeout

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

CI follow-up for run 41819578987 (org-run, 2026-11-04): the openchamber derivation build ran the mcpx test suite, and TestAbstractSocketName hung the full 1800s test timeout inside sdnotify.Send/Ready — in that container environment an abstract unixgram write blocks instead of completing or erroring. The mcpx failure cascaded into the opencode and openchamber derivation builds.

Change (pkgs/mcpx/internal/sdnotify)

  • Send now sets a 5-second write deadline on the notify socket before writing. sd_notify is fire-and-forget; a daemon must never wedge on an unresponsive socket. A blocked write now surfaces as an ordinary wrapped error in bounded time, in production as well as in tests.
  • TestAbstractSocketName runs Ready() under a 15-second watchdog: if the environment blocks abstract-socket writes outright, the test skips with the reason named ("this environment blocks abstract-socket writes") instead of hanging the suite for 1800s. Where abstract sockets work, the test verifies the datagram exactly as before.

Tests

go test ./internal/sdnotify/ -count=1 — 4/4 pass (no-op outside systemd, filesystem socket delivery for Ready/MainPID, abstract socket delivery, missing-socket error). The container failure mode cannot be reproduced on this host (abstract sockets behave); the fix bounds it structurally — deadline in Send, watchdog in the test — rather than by environment detection.

🤖 queue worker lane any-b, task 9439


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…suite

Run 41819578987: TestAbstractSocketName hung the full 1800s test
timeout inside sdnotify.Send in a container where an abstract
unixgram write blocks instead of erroring, cascading the mcpx
failure into the opencode and openchamber derivation builds. Send
now writes under a 5s deadline (sd_notify is fire-and-forget; a
daemon must never wedge on an unresponsive socket), and the test
runs Ready under a 15s watchdog that skips with the environment
reason named instead of hanging. Tests: go test
./internal/sdnotify/ — 4/4.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 10:17
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d670ef3-c660-41c8-97f1-fa1a69765127
Commits

Reviewing files that changed from the base of the PR and between 59ae49a and 670af70.

Files selected for processing: 2

  • pkgs/mcpx/internal/sdnotify/sdnotify.go
  • pkgs/mcpx/internal/sdnotify/sdnotify_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T10:20:00.689968Z 670af70 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 670af70112

ℹ️ 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".

Comment on lines +81 to +82
case <-time.After(15 * time.Second):
t.Skipf("abstract unixgram notify to %s did not complete in 15s; this environment blocks abstract-socket writes", name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a failing regression test for blocked notify writes

If Ready() remains blocked beyond the new five-second write deadline, this watchdog skips rather than detects the regression. On ordinary hosts, the test only writes to an empty socket, so removing SetWriteDeadline would also leave the suite green. Add a regression test that deliberately creates socket backpressure and asserts that Send returns a timeout error within a bounded interval, covering filesystem and abstract sockets. This provides the failing-first coverage required by the scoped instructions.

AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L9-L10

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed on main by #6176 (commit 93707be), which superseded this PR (task 17216, lane any-c).

Main's rework routes Send through an injectable dialer (sendWithDialer) and carries exactly the failing-first deadline coverage requested here: TestSendDialHasDeadline (a blocking dialer must return context.DeadlineExceeded within bounds) and TestSendWriteHasDeadline (asserts the write deadline is actually set on the connection, via a recording conn — removing the deadline call fails this test). Main also bounds the dial as well as the write at 1s.

Verified 2026-11-14: go test ./internal/sdnotify/ -count=1 passes on main. PR #8638 is being closed as superseded with the full evidence on the PR.

@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17216 picked up (lane any-c)

@dezren39 dezren39 added queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state status/in-progress Queue worker lifecycle state labels Nov 14, 2026
@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17216 done: superseded, closing PR #8638 (lane any-c)

This PR's fix already landed on main in a stronger form via commit 93707be ("fix(mcpx): bound sdnotify socket sends (#6176)"), verified fresh 2026-11-14:

  • Main's pkgs/mcpx/internal/sdnotify/sdnotify.go routes Send through sendWithDialer with a 1s notifyTimeout that bounds BOTH the dial (DialContext with context.WithTimeout) and the write (SetWriteDeadline, with its error checked) — this PR bounds only the write at 5s and ignores the deadline error.
  • Main's tests include the deadline regression coverage: TestSendDialHasDeadline (blocking dialer returns context.DeadlineExceeded within bounds) and TestSendWriteHasDeadline (records that a write deadline is actually set) — the substance of the Codex P1 finding on this PR (comment 4536657472, replied to on its thread).
  • Main's TestAbstractSocketName handles environments where abstract sockets are unavailable.
  • Corroborating: rebasing this branch onto current main conflicts in exactly these two files because main rewrote them; go test ./internal/sdnotify/ -count=1 passes on main (ok, 0.050s, run on the laptop at main 646284f).

Closing as superseded per task 17216 acceptance. The head branch is left in place (not deleted).

@dezren39 dezren39 closed this Nov 14, 2026
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 14, 2026
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