You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "danny0405 (via GitHub)" <gi...@apache.org> on 2023/04/10 08:51:46 UTC

[GitHub] [hudi] danny0405 commented on a diff in pull request #8404: [HUDI-6049] split_reader don't checkpoint before consuming all splits

danny0405 commented on code in PR #8404:
URL: https://github.com/apache/hudi/pull/8404#discussion_r1161556062


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/SplitProcessThread.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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.source;
+
+import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.util.function.ThrowingRunnable;
+import org.apache.hudi.adapter.MailboxExecutorAdapter;
+import org.apache.hudi.adapter.RateLimiterAdapter;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.table.format.mor.MergeOnReadInputFormat;
+import org.apache.hudi.table.format.mor.MergeOnReadInputSplit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Queue;
+
+/**
+ *  A separate thread to process splits. Can control read rate by FlinkOptions.READ_RATE_LIMIT
+ */
+public class SplitProcessThread extends Thread {
+
+  private static final Logger LOG = LoggerFactory.getLogger(SplitProcessThread.class);
+  private volatile boolean running = true;
+  private transient Queue<MergeOnReadInputSplit> splits;
+
+  private final MailboxExecutorAdapter executor;
+
+  private MergeOnReadInputFormat format;
+
+  private transient SourceFunction.SourceContext<RowData> sourceContext;
+
+  private transient ThrowingRunnable<? extends Exception> exceptionHandler;
+  private transient Option<RateLimiterAdapter> rateLimiter;
+
+  public SplitProcessThread(Queue<MergeOnReadInputSplit> splits, MailboxExecutorAdapter executor, MergeOnReadInputFormat format,
+                            SourceFunction.SourceContext<RowData> sourceContext, ThrowingRunnable<? extends Exception> exceptionHandler,
+                            int indexOfThisSubtask, int numberOfParallelSubtasks) {
+    setName(String.format("split-process-thread (%s/%s)", indexOfThisSubtask + 1, numberOfParallelSubtasks));
+    this.splits = splits;
+    this.executor = executor;
+    this.format = format;
+    this.sourceContext = sourceContext;
+    this.exceptionHandler = exceptionHandler;
+    long rate = format.getConf().getLong(FlinkOptions.READ_RATE_LIMIT);
+    this.rateLimiter = rate > 0 ? Option.of(RateLimiterAdapter.create(rate)) : Option.empty();
+  }
+
+  @Override
+  public void run() {
+    while (running) {

Review Comment:
   We lost the exactly-once semantics if the consumption is taking place in another thread, that is, when the checkpoint barrier passed by, the consumption offset is not managed synchonously within the state-backend, we consume like 2048 records per-batch, and the discrepancy can be within range [0, 2048].



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org