apache/seatunnel · warning

Close Hudi record writer failed.

Error message

Close Hudi record writer failed.

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/sink/writer/HudiRecordWriter.java:245

        if (!closed) {
            closed = true;
            try {
                flush();
            } catch (Exception e) {
                LOG.warn("Flush records to Hudi failed.", e);
                flushException =
                        new HudiConnectorException(
                                CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,
                                "Flush records to Hudi failed.",
                                e);
            }

            try {
                if (clientProvider != null) {
                    clientProvider.close();
                }
            } catch (Exception e) {
                LOG.warn("Close Hudi record writer failed.", e);
            }
        }
        checkFlushException();
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the logged cause; if it follows a flush failure, fix the root flush error first.
  2. Verify Hudi client configuration (embed timeline server settings) matches the Hudi version in use.
  3. Check for known Hudi write-client close/shutdown issues with your Hudi version and upgrade if affected.
  4. Ensure only one close lifecycle per writer; avoid double-close from task cancel + checkpoint paths.
  5. Treat as a resource-leak risk: monitor worker file-descriptor/memory usage if it recurs.

Example fix

// before
clientProvider.close();
// after
try {
    clientProvider.close();
} catch (Exception e) {
    LOG.warn("Close Hudi record writer failed.", e);
} // already guarded; ensure close() is idempotent and called once
Defensive patterns

Strategy: try-catch

Type guard

// guard before close
if (clientProvider != null) {
    try { clientProvider.close(); } catch (Exception e) { LOG.warn("close failed", e); }
}

Try / catch

try {
    writer.close();
} catch (Exception e) {
    // flush failures surface here; close-time clientProvider failures are
    // only WARN-logged, so check worker logs for 'Close Hudi record writer failed.'
    LOG.warn("Writer close reported cleanup issues", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/4655919bd817234b. Report an issue: GitHub.