[BACKPORT 2026.2][#38182] YSQL: Fix duplicate notifications from retried statements (#38183) #38357
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 304 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.342
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #38357"
general
weight: 0.35
arpang
Summary
A query-layer retry kept the discarded attempt's notifications in
pendingNotifies: the restart does not reset PG-side transaction state,so the retried attempt queued its notifications again, and a
notification whose payload differed between attempts was delivered twice
(#38182).
The retry wrapper (
yb_exec_query_wrapper_one_attempt) now takes a markof the pending notifications when the statement starts and rolls back to
it on retry:
(e.g. JDBC
executeBatch) a retry re-runs only the failing statement,and the notifications queued by earlier statements in the batch must
survive.
READ COMMITTED, the previous statement's notifications move to the top
level only when the next statement starts, so a mark of the top level
alone would make the rollback drop them.
Original commit: 40d627827b1b3499553a385443b447a5d29bdefb / #38183
Test plan
testNotifyFromRetriedStatementDeliveredOnce. Without the fix itfails with
Notifications: [kept, attempt_..., attempt_..., sentinel]. It runs under REPEATABLE READ: under READexpected:<3> but was:<4>
COMMITTED, the default in release builds, the retry rolls back the
statement's internal subtransaction, which drops the attempt's
notifications, so the test passed without the fix there.
testNotifyFromRetriedStatementInReadCommittedBlock: rolling backto the mark keeps the notification queued by the previous statement of a
READ COMMITTED block. It passes without the fix too, for the reason
above.
TestPgListenNotifypasses.Run on a debug build on macOS arm64.
Merge conflicts
master --> 2026.2
java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgListenNotify.java:774— [adjacent-lines] on master the new tests follow #37444'stestNotifyAfterTableReadDeliveredOnce, which isn't on 2026.2; placed them aftertestNotifyInSubtransactioninstead.🤖 Generated with Claude Code
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>