← Back to Pull requests

[BACKPORT 2026.2][#31127] YSQL: Enable LISTEN/NOTIFY by default #39496

Closed
unknown closed this pull request without merging on Nov 27, 2026 11:25 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 06:54 UTC
Author

Summary


Original commit: 43e3cdc7fe5 / D52181

This revision enables LISTEN/NOTIFY by default. ysql_yb_enable_listen_notify becomes a kLocalPersisted AutoFlag (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 twin waitForListenNotifyBootstrap() (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_notify stays 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=false on 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

Diff: 608 lines (+456 / -152) across 7 files Reviewer: arpang Review duration: 270m
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
0.50
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.384
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #39496"
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: 50.1% (MEDIUM) · Higher = larger blast radius
50.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: 19.8% · Safe to merge
19.8%