-
Bug
-
Resolution: Unresolved
-
Major
-
1.4.2.Final
-
None
-
False
-
False
-
Undefined
-
-
There is an ordering issue with graceful shutdown on Postgres databases using Embedded engine. The replication stream is closed before flush.
The following things happen when EmbeddedEngine.close() is called:
- The PostgresStreamingChangeEventSource.execute(..) method is terminated and the following finally block is triggered.
See LOC https://github.com/debezium/debezium/blob/master/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresStreamingChangeEventSource.java#L152-L173public void execute(ChangeEventSourceContext context) throws InterruptedException { ... finally { if (replicationConnection != null) { ... replicationStream.set(null); } } }
- In EmbeddedEngine the finally block of the run method is invoked and this code block is executed:
See LOC: https://github.com/debezium/debezium/blob/86cb71ad8b063a66fff8148a9a2dc94830d21d09/debezium-embedded/src/main/java/io/debezium/embedded/EmbeddedEngine.java#L838-L850finally { ... // Always commit offsets that were captured from the source records we actually processed ... commitOffsets(offsetWriter, commitTimeout, task); ... }
- This triggers the execution of the PostgresStreamingChangeEventSource commitOffset method, but replicationStream was set to null in step 1, so the flushLsn never happens:
See LOC: https://github.com/debezium/debezium/blob/master/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresStreamingChangeEventSource.java#L334-L347@Override public void commitOffset(Map<String, ?> offset) { try { ... if (replicationStream != null && lsn != null) { ... // tell the server the point up to which we've processed data, so it can be free to recycle WAL segments replicationStream.flushLsn(lsn); } ... }
- The shutdown sequence completes with no exceptions raised, despite the complete failure to flush LSNs
- relates to
-
DBZ-3655 Status stays in RUNNING for Postgres Connector after Postgres is stopped
- Closed