-
Notifications
You must be signed in to change notification settings - Fork 25
[Postgres Storage] Ability to use the same server #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 834b990 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
modules/module-postgres-storage/src/storage/batch/PostgresBucketBatch.ts
Show resolved
Hide resolved
modules/module-mongodb-storage/src/storage/MongoBucketStorage.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the mongodb system identifier, I'm happy with the changes. It looks like the MongoDB one is not really used, but if it's there I think we need to make sure the implementation is working properly.
Overview
This PR adds support for using the same Postgres server as both the replication source and sync bucket storage. The same database is also supported, but this should be avoided if possible. This change aims to simplify self-hosting for certain users.
Currently, using the same server is not recommended due to the risk of WAL feedback loops. The Postgres replication module consumes a replication slot using the
pgoutput
plugin and emitskeepalive
events viapg_logical_emit_message
. On older versions of Postgres, the contents of thesekeepalive
events cannot be read, so the module assumes that any empty replication slot event is akeepalive
event.A feedback loop occurs as follows:
Starting with Postgres 14, the
pgoutput
plugin provides access to the contents of logical replication messages. This allows the module to properly distinguish between keepalive events (which we emit) and other external WAL events, preventing feedback loops.To maintain compatibility, an explicit error will be thrown if the same Postgres cluster is used for both the replication source and sync bucket storage on versions below 14. This ensures:
Postgres < 14 remains supported if separate clusters are used.
Postgres 14+ is required if using the same cluster for both purposes.
Additional Items
Some minor Postgres cleanup is also included here. This includes:
Some bugs were identified:
During testing a bug was observed with the Postgres active checkpoint notifications. A crash could occur if a client subscribed to the notification stream after a connection had timed out. This issue has been resolved by cleaning up the listener flow and connection configuration.