← Back to Pull requests

[#36083] YSQL: Make every LISTEN wait for the notifications poller to start #38212

Closed
unknown closed this pull request without merging on Nov 22, 2026 10:16 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 15:42 UTC
Author

Summary

Problem. The first LISTEN on a node starts the notifications poller, and it does so after releasing NotifyQueueLock. Meanwhile, other LISTENs can join:
1. LISTEN A finds no listeners on the node, registers, and starts creating the slot and the poller.
2. LISTEN B arrives, sees A registered, and commits without waiting.
3. A fails before the poller is up (cancel, slot creation error, poller init failure).

B is now registered with no poller. It gets no notifications and no error. Every later LISTEN on the node joins B and is in the same state, until all of them leave.

Fix. Every LISTEN now waits until the poller reports that it initialized, and fails if it didn't. If A leaves before the poller reports, ybCleanupListenState marks the startup failed and stops the poller, so B fails instead of waiting forever. Every way A can leave (abort, FATAL, crash) goes through that function. Once the failed LISTENs have left, the next LISTEN starts a fresh poller.

Alternative rejected. Reusing has_runtime_error would let B's LISTEN commit and then drop its connection with FATAL, instead of failing the LISTEN.

Follow-ups.

  • #38342: under a steady stream of LISTENs after a failed startup, the node may never reach zero listeners, so no new poller starts.

  • #38733: if poller restarts keep failing to initialize, existing listeners stop receiving notifications with no error.
  • Test plan

    New tests: the first LISTEN on a node is delayed in poller init, a second LISTEN joins, then the first fails. The joining LISTEN must fail too, and a later LISTEN must get a working poller. The tests wait until the joining LISTEN shows the BgWorkerStartup wait event, so they always exercise the join.

  • TestPgListenNotify#testListenJoiningCancelledFirstListenFails: the first LISTEN is cancelled. Fails without the fix (the joining LISTEN succeeds).

  • TestPgListenNotify#testListenJoiningFailedPollerInitFails: the poller fails to initialize.
  • Run on a macOS debug build:

    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testListenJoiningCancelledFirstListenFails'
    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testListenJoiningFailedPollerInitFails'
    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testCancelledFirstListenLeavesOnePoller'
    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testListenFailsDueToVirtualWalLimit'
    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testFailedListenKeepsYsqlWebserver'
    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testListenNotifyAfterPeerListenerCrash'
    

    🤖 Generated with Claude Code

    Diff: 339 lines (+254 / -85) across 4 files Reviewer: arpang Review duration: 6874m
    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 #38212"
    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%