Status: Closed (View Workflow)
Affects Version/s: 1.0.0.Final
Fix Version/s: 1.1.0.Beta1
PostgreSQL is unable to shutdown if there is an active Debezium PostgreSQL connector.
For example, we can try to shutdown PostgreSQL manually (command below is used for debezium/postgres:12 Docker image):
But after some time an error will be occured
Server will continue to work, but will disallow any new connection
By default it will send SIGINT signal to postgres process. From PostgreSQL docs:
The server disallows new connections and sends all existing server processes SIGTERM, which will cause them to abort their current transactions and exit promptly. It then waits for all server processes to exit and finally shuts down. If the server is in online backup mode, backup mode will be terminated, rendering the backup useless.
The postgres process will sent Primary keepalive message (B) to replication stream with "The current end of WAL on the server" and wait for stream to sent back Standby status update (F) which will contain "The location of the last WAL byte + 1 applied in the standby". The process will repeat until those locations (lsn) are equal.
The main problem is when Debezium PostgreSQL connector receives Primary keepalive message (at any time) it will not apply lsn from its message (ReplicationStream#flushLsn will not be invoked)
So when PostgreSQL during shutdown process will compare end of WAL on the server and connector's last applied WAL location, it will compare server's last keepalive lsn with some debezium's XLogData lsn. Thus Postgres process will stuck in an infinite cycle and will never shutdown