Skip to content

flake: sigterm_shutdown server shuts down gracefully during startup, before readiness (exit 0, not a port conflict) #751

Description

@TinDang97

Summary

sigterm_clean_exit_shards_4_held_conn (tests/sigterm_shutdown.rs) intermittently fails
because the spawned server shuts down gracefully during startup, before the test's
readiness probe ever succeeds:

[s4-held] server process exited with ExitStatus(unix_wait_status(0))
          before becoming ready on port 49587

Observed once in scripts/ci-local.sh (macOS host tokio suite) under external CPU load.
6 of 7 tests in the binary passed.

What the server log shows

This is not a bind failure or a port conflict. The server came all the way up — 4 shards,
page caches, checkpoint managers, spill threads — and then ran the clean shutdown path
~60 ms after start:

08:29:23.024  Starting with 4 shards
08:29:23.056  Shard 0..3: PageCache initialized
08:29:23.062  Shard 0..3: checkpoint manager initialized
08:29:23.078  Shard 0: spill background thread initialized
08:29:23.078  Shard 0 shutting down          <-- ~60ms after start, before ready
08:29:23.082  Shard 1 shutting down
08:29:23.086  Shard 3 shutting down
08:29:23.090  Shard 2 shutting down
08:29:23.192  Server shut down

stderr carries only the benign <jemalloc>: option background_thread currently supports pthread only. No error, no panic.

Exit status is 0, which per this file's own doc comment means the graceful path ran to
completion — a signal death would report code() == None. So the process was asked to shut
down; it did not crash.

Why this is not the known port flake

The test already uses common::spawn_listening_guarded, the post-#284 helper with
respawn-on-dead-child, and the port is reserve_port-deduped. The failure mode here is a
server that binds and initialises successfully and is then told to stop. That is a different
class from #489 (unique_port()+N unverified ports → connection refused).

Mechanism: NOT determined

I have not established what requests the shutdown that early, and I do not want to guess.
Candidates worth checking, in no particular order:

  • a SIGTERM intended for a previous child arriving after pid reuse
  • process-group signalling from a sibling test in the same binary (7 tests, all of which
    spawn servers and signal them)
  • the shutdown path being armed before readiness is published, so a signal delivered in the
    startup window is honoured rather than deferred

The third would be a genuine server-side ordering bug rather than a test bug, which is why
this is filed rather than waived.

Reproduction

Load-dependent. --test sigterm_shutdown in isolation: 0/6 failed (7 passed each run).
The single observed failure was during a full ci-local run with a foreground app consuming
~175% CPU.

Not caused by the branch it appeared on

Seen on docs/claude-md-native-scope, a docs-only branch whose
git diff main -- src/ tests/ benches/ Cargo.* is empty.

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions