← Back to Pull requests

[pg19][#35965] YSQL: Fix postmaster FATAL after the only LISTEN backend on a node is killed #38976

Closed
unknown closed this pull request without merging on Dec 04, 2026 12:17 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 08:57 UTC
Author

Summary

D59772 enabled postmaster-side cleanup of killed backends on pg19. When a LISTEN backend is killed, the postmaster calls YbCleanupListenStateForProc(). If that backend was the only listener on the node, the cleanup reads the poller shmem structs.

The structs were created on demand with ShmemInitStruct(). In the postmaster, ShmemInitStruct() does not attach to an existing struct; it raises shared memory struct "YbNotifsPollerData" is already initialized. The postmaster exits and the tserver restarts Postgres. Under Connection Manager, the restart breaks Odyssey's control connection (Unable to send auth passthrough request, broken control connection).

Fix: request both structs with ShmemRequestStruct() in AsyncShmemRequest(), the pg19 API for new shmem, and zero them in AsyncShmemInit().

The postmaster then gets the structs' addresses at startup and backends inherit them through fork, so no process, the postmaster included, has to look them up later.

The structs now always exist, so:

  • ybShmemNotifsPollerData() and ybShmemNotifsPollerBgwHandle() lose their found parameter.

  • ybCleanupListenState() loses its found check and Assert(found).

  • The static caches of the poller data pointer are gone. They only saved a ShmemInitStruct() lookup.
  • Test plan

    New test: testNoPostmasterRestartAfterSoloListenerCrash. It kills the only listener on a node and checks that pg_postmaster_start_time() does not change. It sends no NOTIFY after the kill, so it does not depend on #39744.

    Debug build (clang21), each run with and without YB_ENABLE_YSQL_CONN_MGR_IN_TESTS=true:

  • Without the fix, testNoPostmasterRestartAfterSoloListenerCrash fails. Without Connection Manager: Postgres restarted after the listener crash. With Connection Manager: Unable to send auth passthrough request, broken control connection, and the log has the postmaster FATAL "YbNotifsPollerData" is already initialized.

  • With the fix, testNoPostmasterRestartAfterSoloListenerCrash passes.

  • With this PR and #39744, testListenNotifyAfterSoloListenerCrash, testListenNotifyAfterPeerListenerCrash, testNotifyCommitAndNotifierCrash and the new test pass.
  • testListenNotifyAfterSoloListenerCrash also needs #39744. With this PR alone it fails in both modes. Without Connection Manager, the log shows the sequence: the postmaster FATAL is gone, then the notifications poller hits TRAP: failed Assert("pid != InvalidPid") on the entry that the killed listener left in globalChannelTable.

    YB_ENABLE_YSQL_CONN_MGR_IN_TESTS=true ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testNoPostmasterRestartAfterSoloListenerCrash'
    

    Diff: 339 lines (+254 / -85) across 4 files Reviewer: arpang Review duration: 16039m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 339 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #38976"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%