[pg19][#35965] YSQL: Fix postmaster FATAL after the only LISTEN backend on a node is killed #38976
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
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.349
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #38976"
general
weight: 0.35
arpang
Summary
D59772 enabled postmaster-side cleanup of killed backends on pg19. When a LISTEN backend is killed, the postmaster calls
YbCleanupListenStateForProc(). If that backend was the only listener on the node, the cleanup reads the poller shmem structs.The structs were created on demand with
ShmemInitStruct(). In the postmaster,ShmemInitStruct()does not attach to an existing struct; it raisesshared memory struct "YbNotifsPollerData" is already initialized. The postmaster exits and the tserver restarts Postgres. Under Connection Manager, the restart breaks Odyssey's control connection (Unable to send auth passthrough request, broken control connection).Fix: request both structs with
ShmemRequestStruct()inAsyncShmemRequest(), the pg19 API for new shmem, and zero them inAsyncShmemInit().The postmaster then gets the structs' addresses at startup and backends inherit them through fork, so no process, the postmaster included, has to look them up later.
The structs now always exist, so:
ybShmemNotifsPollerData()andybShmemNotifsPollerBgwHandle()lose theirfoundparameter.ybCleanupListenState()loses itsfoundcheck andAssert(found).ShmemInitStruct()lookup.Test plan
New test:
testNoPostmasterRestartAfterSoloListenerCrash. It kills the only listener on a node and checks thatpg_postmaster_start_time()does not change. It sends no NOTIFY after the kill, so it does not depend on #39744.Debug build (clang21), each run with and without
YB_ENABLE_YSQL_CONN_MGR_IN_TESTS=true:testNoPostmasterRestartAfterSoloListenerCrashfails. Without Connection Manager:Postgres restarted after the listener crash. With Connection Manager:Unable to send auth passthrough request, broken control connection, and the log has the postmaster FATAL"YbNotifsPollerData" is already initialized.testNoPostmasterRestartAfterSoloListenerCrashpasses.testListenNotifyAfterSoloListenerCrash,testListenNotifyAfterPeerListenerCrash,testNotifyCommitAndNotifierCrashand the new test pass.testListenNotifyAfterSoloListenerCrashalso needs #39744. With this PR alone it fails in both modes. Without Connection Manager, the log shows the sequence: the postmaster FATAL is gone, then the notifications poller hitsTRAP: failed Assert("pid != InvalidPid")on the entry that the killed listener left inglobalChannelTable.