{"record":{"id":"8fc0f825b3732cc3","repo":"apache/seatunnel","slug":"failed-to-close-pulsar-sink-writer","errorCode":null,"errorMessage":"Failed to close Pulsar sink writer.","messagePattern":"Failed to close Pulsar sink writer\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/sink/PulsarSinkWriter.java","lineNumber":395,"sourceCode":"                throwable);\n    }\n\n    private Throwable appendSuppressed(Throwable existingFailure, Throwable newFailure) {\n        if (existingFailure == null) {\n            return newFailure;\n        }\n        existingFailure.addSuppressed(newFailure);\n        return existingFailure;\n    }\n\n    private void rethrowCloseFailure(Throwable throwable) throws IOException {\n        if (throwable instanceof IOException) {\n            throw (IOException) throwable;\n        }\n        if (throwable instanceof RuntimeException) {\n            throw (RuntimeException) throwable;\n        }\n        throw new IOException(\"Failed to close Pulsar sink writer.\", throwable);\n    }\n\n    @Override\n    public MultiTableResourceManager<Void> initMultiTableResourceManager(\n            int tableSize, int queueSize) {\n        return null;\n    }\n\n    @Override\n    public void setMultiTableResourceManager(\n            MultiTableResourceManager<Void> multiTableResourceManager, int queueIndex) {\n        // Pulsar sink does not require shared resources across tables\n    }\n}\n","sourceCodeStart":377,"sourceCodeEnd":410,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/sink/PulsarSinkWriter.java#L377-L410","documentation":"PulsarSinkWriter.rethrowCloseFailure normalizes any non-IOException/non-RuntimeException throwable raised while releasing producers/client/transactions during close() into a plain IOException with this message, preserving the original as the cause. It signals resource cleanup failed (e.g. an Error or checked non-IO exception).","triggerScenarios":"close() accumulates a throwable from closing producers, flushing pending sends, or closing the PulsarClient/transaction, and the throwable is neither IOException nor RuntimeException; rethrowCloseFailure wraps it.","commonSituations":"Async send failures surfacing during flush-on-close; errors thrown by custom classloader cleanup (see related tests); JVM-level Error (e.g. OOM) during close; unexpected library exception type from a Pulsar client upgrade.","solutions":["Inspect the cause chain in the stack trace for the underlying close/flush failure and fix that root cause.","Ensure pending async sends succeed (broker reachable, producer healthy) before job teardown.","Upgrade/align the Pulsar client version if an unexpected exception class escapes cleanup."],"exampleFix":"// before\n// writer.close() throws IOException caused by Error during cleanup\n// after: log & fix root cause, e.g. guard custom classloader usage\ntry (final PulsarSinkWriter w = createWriter()) {\n  w.write(row);\n} // ensure close succeeds; inspect cause if this error appears","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    writer.close();\n} catch (IOException e) {\n    log.error(\"Pulsar sink writer close failed; inspect cause\", e);\n    throw e; // rethrow to fail the task, cause holds the real error\n}","preventionTips":["Always inspect the exception cause chain; the message is generic by design.","Ensure broker connectivity stays healthy through job teardown.","Keep Pulsar client versions aligned between connector and cluster."],"tags":["pulsar","sink","resource-cleanup"],"backgroundTag":"internal-invariant-violation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}