Skip to content

server: main exits before graceful shutdown (drain, WAL checkpoint, dbClose) completes #577

Closed

Description

@dborup

Found in the #571 review (Minimax). This is pre-existing and was not changed by #571.

cmd/server/main.go: main returns as soon as ListenAndServe returns ErrServerClosed. That happens at the start of httpServer.Shutdown, and main does not wait for the shutdown goroutine. As a result, the client drain, the WAL checkpoint and dbClose race process exit. The deferred stopPingScoreHistory happens to buy time.

Fix: main waits on a done channel from the shutdown goroutine, with a bounded timeout. Add a process test asserting that "shutdown complete" is logged and that the DB is closed cleanly on SIGTERM.

Relates to #571.

Activity

  1. dborup commented on Oct 25, 2026

    @dborup
    OwnerAuthor

    Fixed by #582 (merged as fe3b650c3c25abb2cccfb471495158b84cab90de).

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions