[BACKPORT 2026.2][#31127] YSQL: Enable LISTEN/NOTIFY by default #39496
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 608 lines diff across 7 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.384
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #39496"
general
weight: 0.35
arpang
Summary
Original commit: 43e3cdc7fe5 / D52181
This revision enables LISTEN/NOTIFY by default.
ysql_yb_enable_listen_notifybecomes akLocalPersistedAutoFlag (initial false, target true).With this, the background task (yb_system db, pg_yb_notifications table and pg_yb_notifications_publication creation) executes asynchronously with all the tests and causes non-deterministic failures (db list mismatch, catalog version mismatch, rpc/connection mismatch, etc.). This is addressed by:
- Initdb creates yb_system db. This ensures yb_system is present at the start of each test. This also reduces conflict with other global DDLs (say, another CREATE DATABASE). The migration script does not support CREATE DATABASE, so we will still need a background job to create the DB on a pre-existing universe. The only difference is in the range that the DB's oid belongs to. Initdb allocated oid will be in [FirstUnpinnedObjectId, FirstNormalObjectId), whereas the one allocated by bg task will be >= FirstNormalObjectId range. Both ranges are unpinned, so there's no difference in user-facing behaviour. Update TestYsqlUpgrade.java to accept this difference. Also, add db comment in CreateYbSystemDBIfNeeded(), just like initdb does.
- The bg task runs its CREATE TABLE / CREATE PUBLICATION with yb_enable_invalidation_messages off and yb_make_next_ddl_statement_nonincrementing on, so yb_system's catalog version does not depend on when the task runs.
- A shared wait helper,
WaitForListenNotifyBootstrap()(libpq_utils.h, with no-arg members on LibPqTestBase and PgMiniTestBase) and its Java twinwaitForListenNotifyBootstrap()(BasePgSQLTest), polls yb_system until the publication exists. The wait covers the first run only. A restarted master re-runs the bootstrap as a no-op that the wait cannot observe, so a test that needs a quiet window after a restart turns the flag off for that restart.Upgrade/Rollback safety
- New universes: initdb creates yb_system. The master creates pg_yb_notifications and its publication at startup.
- Upgraded universes:
ysql_yb_enable_listen_notifystays false until the upgrade is finalized and AutoFlags are promoted. After promotion, the master creates yb_system (normal-range OID), the table and the publication in the background.- Rollback before finalize leaves no new objects. After promotion, yb_system and its objects remain. 2025.2 and 2026.1 already ship this flag and the bootstrap code, so their binaries tolerate these objects; with their default of false they do not use them.
- Opt out: set
ysql_yb_enable_listen_notify=falseon masters and tservers.Test changes:
Wait for the bootstrap to finish
- pg_catalog_perf-test, pg_libpq-test (NumberOfInitialRpcs), pg_fkey-test, pg_mini-test, pg_object_locks-test, pg_shared_mem-test, pg_index_backfill-test, pg_cgroups-test, pg_catalog_version-test, pg_tablet_split-test, pg_ash-test (PgCDCServiceRPCs), yb-admin-test, yb-admin-snapshot-schedule-test, tablet_limits_integration_test, upgrade tests (in
UpgradeTestBase::FinalizeUpgrade()), TestMasterMetrics, TestPgConnection, TestPgSelect, TestYsqlUpgrade- async_writes-test (YSqlAsyncWriteTest). It runs 3 masters and only one tserver runs PG, so all tservers now share that PG (
TEST_pg_auth_key) and the bootstrap completes whichever master leads.Disable LISTEN/NOTIFY
Tests turn the flag off where a wait does not help.
- The bootstrap takes an id the test hard-codes: pg_libpq-test (PgOidCollisionTestBase, OIDs), pg_mini-test (PgRecursiveAbortTest, PG session ids)
- Its table changes tablet counts or leader moves the test depends on: load_balancer_colocated_tables-test, pg_object_locks-test (LegacyRewriteNeverEmptiesLegacyReader)
- The test asserts exact CDC stream contents, and in these MiniCluster tests the bootstrap does not complete reliably because only one tserver runs PG: cdcsdk_consumption_consistent_changes-test (whole class), cdcsdk_ysql-test (TestPollingPgCatalogTables, TestPollingPgCatalogTablesAfterLeaderStepDown)
- The test wipes the sys catalog under an in-flight bootstrap DDL: orphaned_tablet_cleanup-test (PreviousBehaviorWithNoDeletionCheck)
- A restarted master re-runs the bootstrap inside an RPC count window: pg_catalog_version-test (TestConnectionManagerRelCacheInitRpcCount and InvalMessageDeltaTableLoad, after their restarts)
- TestYbServersMetrics: with the flag on, the connection after its tserver kill intermittently hangs. The cause is not established.
Filter out yb_system
- pg_stat_activity-test (backends), pg_catalog_version-test (relcache init files)
Update expected output
- yb.orig.catalog_version.out, yb.orig.catalog_version_1.out, yb.orig.feature_alter_rename.out, yb.orig.reset_analyze.out, pg_call_home-test, pg_catalog_version-test (InvalMessageSampleDDLs)
Test plan
Jenkins