zhangyue19921010 commented on code in PR #6133:
URL: https://github.com/apache/hudi/pull/6133#discussion_r1028313523
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java:
##########
@@ -187,8 +194,54 @@ protected Path makeNewFilePath(String partitionPath,
String fileName) {
* @param partitionPath Partition path
*/
protected void createMarkerFile(String partitionPath, String dataFileName) {
- WriteMarkersFactory.get(config.getMarkersType(), hoodieTable, instantTime)
- .create(partitionPath, dataFileName, getIOType());
+ WriteMarkers writeMarkers =
WriteMarkersFactory.get(config.getMarkersType(), hoodieTable, instantTime);
+ // do early conflict detection before create markers.
+ if (config.getWriteConcurrencyMode().supportsOptimisticConcurrencyControl()
+ && config.isEarlyConflictDetectionEnable()) {
+ HoodieEarlyConflictDetectionStrategy earlyConflictDetectionStrategy =
config.getEarlyConflictDetectionStrategy();
+ if (earlyConflictDetectionStrategy instanceof
HoodieTransactionDirectMarkerBasedEarlyConflictDetectionStrategy) {
+ createMarkerWithTransaction(earlyConflictDetectionStrategy,
writeMarkers, partitionPath, dataFileName);
+ } else {
+ createMarkerWithEarlyConflictDetection(earlyConflictDetectionStrategy,
writeMarkers, partitionPath, dataFileName);
+ }
+ } else {
+ // create marker directly
+ writeMarkers.create(partitionPath, dataFileName, getIOType());
+ }
+ }
+
+ private Option<Path>
createMarkerWithEarlyConflictDetection(HoodieEarlyConflictDetectionStrategy
resolutionStrategy,
+ WriteMarkers
writeMarkers,
+ String
partitionPath,
+ String
dataFileName) {
+ Set<HoodieInstant> completedCommitInstants =
hoodieTable.getMetaClient().getActiveTimeline()
Review Comment:
For transaction `hasCommitConflict()` checking, we are now reloading active
timeline to get these infos at the beginning of the transaction
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]