{"record":{"id":"47670120e013478d","repo":"apache/seatunnel","slug":"received-unexpected-exception-will-perform-keep-al","errorCode":null,"errorMessage":"received unexpected exception will perform keep alive","messagePattern":"received unexpected exception will perform keep alive","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java","lineNumber":667,"sourceCode":"            public Lsn lastReceivedLsn() {\n                return lastReceivedLsn;\n            }\n\n            @Override\n            public void startKeepAlive(ExecutorService service) {\n                if (keepAliveExecutor == null) {\n                    keepAliveExecutor = service;\n                    keepAliveRunning = new AtomicBoolean(true);\n                    keepAliveExecutor.submit(\n                            () -> {\n                                while (keepAliveRunning.get()) {\n                                    try {\n                                        LOGGER.trace(\n                                                \"Forcing status update with replication stream\");\n                                        stream.forceUpdateStatus();\n                                        metronome.pause();\n                                    } catch (Exception exp) {\n                                        throw new RuntimeException(\n                                                \"received unexpected exception will perform keep alive\",\n                                                exp);\n                                    }\n                                }\n                            });\n                }\n            }\n\n            @Override\n            public void stopKeepAlive() {\n                if (keepAliveExecutor != null) {\n                    keepAliveRunning.set(false);\n                    keepAliveExecutor.shutdownNow();\n                    keepAliveExecutor = null;\n                }\n            }\n\n            private void processWarnings(final boolean forced) throws SQLException {","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java#L649-L685","documentation":"The keep-alive thread that periodically forces status updates on the replication stream hit an unexpected exception (e.g. the stream/socket broke, or the backend terminated). startKeepAlive wraps any exception from stream.forceUpdateStatus() in a RuntimeException with this message, since failing to send keep-alives will let the server drop the slot/WAL.","triggerScenarios":"startKeepAlive's scheduled metronome task calls stream.forceUpdateStatus() and the underlying PGStream throws (connection dropped by server/network, thread interrupted, stream already closed because main streaming failed).","commonSituations":"Network partitions or firewall idle timeouts killing the replication connection; PostgreSQL restart during keep-alive; connector shutting down while the keep-alive executor is still running; long GC pause causing socket timeout.","solutions":["Inspect the wrapped cause (exp) to find the real failure — usually a broken replication connection","Restart the connector/task so the replication connection is re-established (Debezium will resume from the last confirmed LSN)","Ensure network devices do not kill idle connections; keep keep-alive interval below firewall/timeout thresholds","Fix shutdown ordering so the keep-alive thread is stopped before the stream is closed"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check network stability to the DB before starting:\n// SELECT 1 FROM pg_stat_replication; and verify no firewall drops long-lived TCP sessions","typeGuard":null,"tryCatchPattern":"try {\n    keepAliveFuture.get(timeout, TimeUnit.SECONDS);\n} catch (ExecutionException e) {\n    Throwable cause = e.getCause();\n    if (cause.getMessage() != null && cause.getMessage().contains(\"received unexpected exception will perform keep alive\")) {\n        // underlying replication connection broke: reconnect/resume streaming from last confirmed LSN\n        restartStreamingTask();\n    }\n}","preventionTips":["Keep keep-alive interval below firewall/NAT idle timeouts","Monitor replication connection health (pg_stat_replication)","Ensure clean shutdown stops the keep-alive scheduler before closing the stream","Tune TCP keepalives on the JDBC/replication connection"],"tags":["cdc","postgres","opengauss","keep-alive","network","replication"],"backgroundTag":"broken-pipe","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}