TengHuo commented on code in PR #9472: URL: https://github.com/apache/hudi/pull/9472#discussion_r1303746084
########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/cluster/ReplaceCommitValidateUtil.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hudi.table.action.cluster; + +import org.apache.hudi.common.model.HoodieReplaceCommitMetadata; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.util.JsonUtils; +import org.apache.hudi.exception.HoodieException; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Stream; + +import static org.apache.hudi.common.util.FileIOUtils.LOG; + +public class ReplaceCommitValidateUtil { + public static final String REPLACE_COMMIT_FILE_IDS = "replaceCommitFileIds"; + public static void validateReplaceCommit(HoodieTableMetaClient metaClient) { + metaClient.reloadActiveTimeline(); + Set<String> replaceFileids = new HashSet<>(); + + // Verify pending and completed replace commit + Stream.concat(metaClient.getActiveTimeline().getCompletedReplaceTimeline().getInstantsAsStream(), + metaClient.getActiveTimeline().filterInflights().filterPendingReplaceTimeline().getInstantsAsStream()).map(instant -> { + try { + HoodieReplaceCommitMetadata replaceCommitMetadata = + HoodieReplaceCommitMetadata.fromBytes(metaClient.getActiveTimeline().getInstantDetails(instant).get(), + HoodieReplaceCommitMetadata.class); Review Comment: I think this issue is caused by different writers isolation from each other, and there is no lock in Hudi timeline, so when one writer is trying to `validateReplaceCommit`, it's impossible to guarantee that there is no other writer is modifying the same timeline. As @boneanxs mentioned, there could be other situation such as two `insert overwrite` running together, or `compaction` and `clustering` generating plan at the same time, the current timeline can't provide enough information (any partitions modified or dropped) to each writer to prevent these concurrent issue. In Hudi [RFC-56](https://github.com/apache/hudi/blob/master/rfc/rfc-56/rfc-56.md), OCC was introduced for solving write conflicts in file group level, but no conflict check in partition level. So I think this partition level conflict issue should be solved in OCC framework, it's better because all similar situation can be solved as long as OCC enabled. cc @voonhous -- 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]
