← Back to Pull requests

[BACKPORT 2025.2][#35212,#35247] YSQL: Always write NOTIFY rows in the statement's transaction (#37444) #38356

Closed
unknown closed this pull request without merging on Nov 18, 2026 15:02 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 09:41 UTC
Author

Summary

Outside a transaction block, the rows for NOTIFY were written to
pg_yb_notifications with single-shard writes, which commit at once.
When the statement had already read a table, the notification's cleanup
DELETE ran at that older read time, found the row its own INSERT had
just committed, and raised Restart read required:

  • Simple query protocol: the query layer retried the statement, so the

  • notification was sent twice and both rows stayed in
    pg_yb_notifications.
  • Extended protocol (JDBC and most drivers): an implicit transaction

  • commits at Sync, outside the retry wrapper, so the statement failed
    while its notification was still delivered (#35212).

    ybInsertPendingNotifiesToTable now always writes in the statement's
    transaction, so the INSERT/DELETE pair commits with it.

    TestPgRegressPgAsync waits longer for notifications on sanitizer
    builds: a statement's notifications are queued only once its whole
    transaction has been streamed, which for the 1000-notification step
    takes over a second there.

    Original commit: 85e84ddd75fc8b715d17471e0036eb9499b99a5f / #37444

    Test plan

  • testNotifyAfterTableReadDeliveredOnce. Without the fix it fails

  • with expected:<[simple, simple_sentinel]> but was:<[simple, simple,
    simple_sentinel]>
    ; over the extended protocol the statement fails with
    Restart read required.
  • TestPgListenNotify passes.

  • Manual before/after on a single-node cluster: triggers, procedures

  • with COMMIT, DDL event triggers, rollback, read-only and serializable
    behave as before; yb_read_time still rejects writes.

    ./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgListenNotify#testNotifyAfterTableReadDeliveredOnce'
    ./yb_build.sh debug --java-test org.yb.pgsql.TestPgListenNotify
    

    Run on a debug build on macOS arm64.

    Merge conflicts

    2026.1 --> 2025.2


    No conflicts.

    2026.2 --> 2026.1


  • java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRegressPgAsync.java:79 — [missing-prerequisite] 2026.1 waits 500 ms; took this commit's nonSanitizerVsSanitizer(1000, 3000), which also brings the 1000 ms wait from cb36dcf3a0b (#33627), not on 2026.1.
  • master --> 2026.2


  • src/postgres/src/backend/commands/async.c:3121 — [missing-prerequisite] dropped the persist_missing_row argument of YBCExecuteDelete, which 2026.2 lacks (master added it in c3bbe5de4c0, online schema change part 3); kept this commit's new true and YB_TRANSACTIONAL arguments.
  • 🤖 Generated with Claude Code

    ---------

    Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
    Co-authored-by: Arpan Agrawal <arpan3495@gmail.com>

    Diff: 329 lines (+246 / -83) across 4 files Reviewer: arpang Review duration: 320m
    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 · 329 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.347
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #38356"
    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.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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.6% · Safe to merge
    16.6%