← Back to Pull requests

[#38556,#38733] YSQL: Restart the notifications poller on errors instead of terminating listeners #38903

Closed
unknown closed this pull request without merging on Nov 26, 2026 16:15 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 14:34 UTC
Author

Summary

Problem. The notifications poller reads pg_yb_notifications through the virtual WAL. The virtual WAL retries only a few known tablet errors itself (kRetryableErrorPatterns: not leader, tablet not running, ...) and passes everything else up, because walsender's client is expected to reconnect and resume. The poller instead treated every such error as fatal and terminated all listeners on the node, even for transient ones like a TimedOut RPC during a leader move. Listeners lost notifications until they reconnected. Separately, a poller that failed to restart didn't tell its listeners, which stayed connected but silently received no new notifications (#38733).

Fix. The poller now recovers the way a walsender client does: it exits and the postmaster restarts it from the slot's restart LSN. This is safe because it acks only after writing to the queue, and listeners skip replayed entries (#30947). Listeners see a delay instead of a disconnect.

Listeners are still terminated when restarting can't help:

  • Permanent errors: the stream has expired, or replication commands are disabled. Startup detects both; any other error, including a missing slot or publication, falls under the no-progress timeout.

  • No progress for longer than yb_notifications_poller_no_progress_timeout_ms when an error hits. Progress means acking a transaction, or an empty read between transactions. A poller stuck replaying a failing transaction makes none, so it gets terminated; a healthy poller keeps making it, so its transient errors never add up.
  • Known limits. A transaction that takes longer than the timeout to stream and then hits an error terminates the listeners. Also, a LISTEN issued while the poller is restarting can receive notifications from transactions that committed shortly before it, as it can whenever the poller lags; restarts make that lag longer.

    Closes #38556, closes #38733.

    Test plan

    ./yb_build.sh release --java-test 'org.yb.pgsql.TestPgListenNotify#<test>', release on macOS arm64:
    All passed locally before the switch to the no-progress timeout; the current head is covered by CI only, and testLaterErrorAfterProgressRestartsPoller has not run locally.

  • New: testPollerRestartsAfterTransientError, testLaterErrorAfterProgressRestartsPoller, testRestartedPollerRecoversFromInitFailure, testRestartedPollerInitFailureTerminatesListeners

  • Updated: testPollerErrorHoldingQueueLock, testCdcRuntimeErrorBlocksNewListener

  • Unchanged: testCdcRuntimeErrorTerminatesListeners (real stream expiry), testPollerRestartDoesNotRedeliverNotifications, testListenJoiningFailedPollerInitFails
  • 🤖 Generated with Claude Code

    Diff: 343 lines (+257 / -86) across 4 files Reviewer: arpang Review duration: 5860m
    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 · 343 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 #38903"
    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%