← Back to Pull requests

[pg19][#35965] YSQL: Purge globalChannelTable entries of a killed LISTEN backend #39744

Open
unknown opened this pull request with 229 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 30, 2026 14:30 UTC
Author

Summary

pg19 keeps channel listeners in a DSA-backed dshash. When a LISTEN backend is killed, the postmaster calls YbCleanupListenStateForProc(). The postmaster cannot attach to DSA (dsm_attach() asserts IsUnderPostmaster), so the entries of the killed listener stay in globalChannelTable. SignalBackends() then hits Assert(pid != InvalidPid).

Changes:

  • SignalBackends() skips entries whose PID is invalid.

  • YbCleanupListenStateForProc() sets a new per-slot flag, ybNeedsChannelPurge. The next backend with that ProcNumber that registers as a listener removes the entries in ybRemoveStaleListenerEntries() and clears the flag. Without the purge, that backend inherits removeOnAbort = false, skips ybOnListenCommit(), and its session never becomes sticky under Connection Manager.

  • YbCleanupListenStateForProc() also resets WAKEUP_PENDING and IS_ADVANCING, as asyncQueueUnregister() does.
  • Test plan

    Debug build (clang21), each run with and without YB_ENABLE_YSQL_CONN_MGR_IN_TESTS=true. The runs applied this change on eda8cc23810, the base of #38976, not on the current pg19 tip.

  • testListenNotifyAfterPeerListenerCrash passes with this PR alone. A second listener survives the kill, so the test does not reach the postmaster FATAL that #38976 fixes.

  • With this PR and #38976, testListenNotifyAfterSoloListenerCrash, testListenNotifyAfterPeerListenerCrash, testNotifyCommitAndNotifierCrash and testNoPostmasterRestartAfterSoloListenerCrash pass. Under Connection Manager, the logs of the first three contain no already initialized, TRAP:, terminating any other active or broken control connection lines.
  • YB_ENABLE_YSQL_CONN_MGR_IN_TESTS=true ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testListenNotifyAfterPeerListenerCrash'
    

    Diff: 229 lines (+171 / -58) across 2 files Reviewer: arpang Review duration: 6274m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 229 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.325
    Real PR Conversation Timeline
    1 comments
    "Review active on #39744"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 37.0% (MEDIUM) · Higher = larger blast radius
    37.0%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 19.7% · Safe to merge
    19.7%