[HUDI-1895] Close the file handles gracefully for flink write function to avoid corrupted files (#2938)
This commit is contained in:
@@ -200,7 +200,7 @@ public class StreamWriteFunction<K, I, O>
|
||||
@Override
|
||||
public void close() {
|
||||
if (this.writeClient != null) {
|
||||
this.writeClient.cleanHandles();
|
||||
this.writeClient.cleanHandlesGracefully();
|
||||
this.writeClient.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class StreamWriteOperatorCoordinator
|
||||
"The coordinator can only handle BatchWriteSuccessEvent");
|
||||
BatchWriteSuccessEvent event = (BatchWriteSuccessEvent) operatorEvent;
|
||||
// the write task does not block after checkpointing(and before it receives a checkpoint success event),
|
||||
// if it it checkpoints succeed then flushes the data buffer again before this coordinator receives a checkpoint
|
||||
// if it checkpoints succeed then flushes the data buffer again before this coordinator receives a checkpoint
|
||||
// success event, the data buffer would flush with an older instant time.
|
||||
ValidationUtils.checkState(
|
||||
HoodieTimeline.compareTimestamps(instant, HoodieTimeline.GREATER_THAN_OR_EQUALS, event.getInstantTime()),
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HoodieTableFactory implements DynamicTableSourceFactory, DynamicTab
|
||||
// Utilities
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** Validate required options. e.g record key and pre combine key.
|
||||
/** Validate required options. For e.g, record key and pre_combine key.
|
||||
*
|
||||
* @param conf The table options
|
||||
* @param schema The table schema
|
||||
@@ -115,17 +115,17 @@ public class HoodieTableFactory implements DynamicTableSourceFactory, DynamicTab
|
||||
Arrays.stream(conf.get(FlinkOptions.RECORD_KEY_FIELD).split(","))
|
||||
.filter(field -> !fields.contains(field))
|
||||
.findAny()
|
||||
.ifPresent(e -> {
|
||||
throw new ValidationException("The " + e + " field not exists in table schema."
|
||||
+ "Please define primary key or modify hoodie.datasource.write.recordkey.field option.");
|
||||
.ifPresent(f -> {
|
||||
throw new ValidationException("Field '" + f + "' does not exist in the table schema."
|
||||
+ "Please define primary key or modify 'hoodie.datasource.write.recordkey.field' option.");
|
||||
});
|
||||
}
|
||||
|
||||
// validate pre combine key
|
||||
// validate pre_combine key
|
||||
String preCombineField = conf.get(FlinkOptions.PRECOMBINE_FIELD);
|
||||
if (!fields.contains(preCombineField)) {
|
||||
throw new ValidationException("The " + preCombineField + " field not exists in table schema."
|
||||
+ "Please check write.precombine.field option.");
|
||||
throw new ValidationException("Field " + preCombineField + " does not exist in the table schema."
|
||||
+ "Please check 'write.precombine.field' option.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user