{"record":{"id":"4655919bd817234b","repo":"apache/seatunnel","slug":"close-hudi-record-writer-failed","errorCode":null,"errorMessage":"Close Hudi record writer failed.","messagePattern":"Close Hudi record writer failed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/sink/writer/HudiRecordWriter.java","lineNumber":245,"sourceCode":"        if (!closed) {\n            closed = true;\n            try {\n                flush();\n            } catch (Exception e) {\n                LOG.warn(\"Flush records to Hudi failed.\", e);\n                flushException =\n                        new HudiConnectorException(\n                                CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                                \"Flush records to Hudi failed.\",\n                                e);\n            }\n\n            try {\n                if (clientProvider != null) {\n                    clientProvider.close();\n                }\n            } catch (Exception e) {\n                LOG.warn(\"Close Hudi record writer failed.\", e);\n            }\n        }\n        checkFlushException();\n    }\n}\n","sourceCodeStart":227,"sourceCodeEnd":251,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/sink/writer/HudiRecordWriter.java#L227-L251","documentation":"During HudiRecordWriter.close(), after the flush attempt, the underlying Hudi clientProvider (write client) is closed. If clientProvider.close() throws, it is logged as a warning ('Close Hudi record writer failed.') and swallowed — it does not create a flushException and does not fail the task directly. It indicates Hudi write-client resources (embedded timeline server, file handles, underlying FS handles) may not have been released cleanly.","triggerScenarios":"clientProvider != null and its close() (wrapping the Hoodie write client shutdown) throws an Exception — typically during Hudi write client shutdown when an earlier write/flush already failed, or when the embedded timeline server / meta client cannot be shut down.","commonSituations":"A preceding FLUSH_DATA_FAILED leaves the Hudi write client in a bad state, so its close also fails; embedded timeline server not terminating; filesystem handles already closed by a prior shutdown step; Hudi version-specific shutdown bugs.","solutions":["Read the logged cause; if it follows a flush failure, fix the root flush error first.","Verify Hudi client configuration (embed timeline server settings) matches the Hudi version in use.","Check for known Hudi write-client close/shutdown issues with your Hudi version and upgrade if affected.","Ensure only one close lifecycle per writer; avoid double-close from task cancel + checkpoint paths.","Treat as a resource-leak risk: monitor worker file-descriptor/memory usage if it recurs."],"exampleFix":"// before\nclientProvider.close();\n// after\ntry {\n    clientProvider.close();\n} catch (Exception e) {\n    LOG.warn(\"Close Hudi record writer failed.\", e);\n} // already guarded; ensure close() is idempotent and called once","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// guard before close\nif (clientProvider != null) {\n    try { clientProvider.close(); } catch (Exception e) { LOG.warn(\"close failed\", e); }\n}","tryCatchPattern":"try {\n    writer.close();\n} catch (Exception e) {\n    // flush failures surface here; close-time clientProvider failures are\n    // only WARN-logged, so check worker logs for 'Close Hudi record writer failed.'\n    LOG.warn(\"Writer close reported cleanup issues\", e);\n}","preventionTips":["Fix any FLUSH_DATA_FAILED errors first — they often cause the subsequent close failure.","Ensure the Hudi client library version's shutdown path is stable (upgrade if close-time NPEs/hangs are known).","Configure embedded timeline server appropriately or disable it if it fails to stop.","Avoid double-close paths (cancel + checkpoint) racing on the same writer.","Monitor worker FD/memory for leaks when this warning recurs."],"tags":["hudi","sink","resource-cleanup"],"backgroundTag":"unsupported-operation","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"}