diff --git a/paimon-core/src/main/java/org/apache/paimon/io/RollingFileWriter.java b/paimon-core/src/main/java/org/apache/paimon/io/RollingFileWriter.java index 109b7574304e..a3057fa483fd 100644 --- a/paimon-core/src/main/java/org/apache/paimon/io/RollingFileWriter.java +++ b/paimon-core/src/main/java/org/apache/paimon/io/RollingFileWriter.java @@ -78,7 +78,12 @@ public void write(T row) throws IOException { openCurrentWriter(); } - currentWriter.write(row); + try { + currentWriter.write(row); + } catch (Throwable e) { + currentWriter = null; + throw e; + } recordCount += 1; if (rollingFile()) { @@ -102,7 +107,12 @@ public void writeBundle(BundleRecords bundle) throws IOException { openCurrentWriter(); } - currentWriter.writeBundle(bundle); + try { + currentWriter.writeBundle(bundle); + } catch (Throwable e) { + currentWriter = null; + throw e; + } recordCount += bundle.rowCount(); if (rollingFile()) {