atepg: deliver worker watch events via a transactional change feed - #934
Open
shrutiyam-glitch wants to merge 1 commit into
Open
atepg: deliver worker watch events via a transactional change feed#934shrutiyam-glitch wants to merge 1 commit into
shrutiyam-glitch wants to merge 1 commit into
Conversation
Replaces per-write pg_notify with a worker_changes outbox table written in the same transaction, and LISTEN with a 100ms polling watcher. pg_notify serializes the commits of all notifying transactions through a global lock held across the commit (fsync included), capping worker writes at ~600/s on Cloud SQL regardless of instance size — measured p50 610ms at 1k updates/s vs 4.9ms with the feed, which sustains >2k/s. The requirements target O(10K) worker updates/s. Also removes NOTIFY's 8KB payload limit (which failed the write) and lets watchers survive reconnects/failovers via their cursor instead of missing events. Known pathology with public prior art: https://www.recall.ai/blog/postgres-listen-notify-does-not-scale https://www.dbos.dev/blog/postgres-listen-notify-scalability (upstream Postgres fix lands in PG 19; unavailable on Cloud SQL).
shrutiyam-glitch
force-pushed
the
atepg-change-feed
branch
from
August 13, 2026 20:56
c1a2eae to
b9b3c72
Compare
shrutiyam-glitch
requested review from
Eitan Yarmush (EItanya) and
Julian Gutierrez Oschmann (juli4n)
August 13, 2026 20:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #920 partially.
Replaces per-write pg_notify with a worker_changes outbox table written in the same transaction, and LISTEN with a 100ms polling watcher.
Motivation
pg_notifyserializes the commits of all notifying transactions through a global lock held across the commit (includingfsync). This artificially caps worker writes at ~600/s on Cloud SQL regardless of instance size, whereas our target is O(10K) worker updates/s.NOTIFYpayload limit that previously caused writes to fail.LISTENapproach.(Known Postgres pathology prior art: Recall.ai, DBOS).
Performance Improvement
WorkerUpdate @ 1,000 QPS , 1M workers (preloaded) — before vs after the change feed:
Changes Made
worker_changes.worker_changesfeed inside the same transaction instead of callingpg_notify().LISTENinWatchWorkerswith a polling watcher that queries the feed every 100ms.pg_notifypayloads.