wuchong commented on code in PR #2510:
URL: https://github.com/apache/fluss/pull/2510#discussion_r2867270609
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/reader/FlinkSourceSplitReader.java:
##########
@@ -109,6 +111,10 @@ public class FlinkSourceSplitReader implements
SplitReader<RecordAndPos, SourceS
private final Map<TableBucket, Long> stoppingOffsets;
private LakeSplitReaderGenerator lakeSplitReaderGenerator;
+ private final SourceReaderContext context;
+ private final Map<TableBucket, Long> backlogMarkedOffsets;
+ private final Set<TableBucket> onlySnapshotBuckets;
+ private final Set<TableBucket> backlogEventSentTbls = new HashSet<>();
Review Comment:
For partitioned tables, frequent creation and removal of partitions mean
that caching all `TableBucket` instances without cleanup will lead to memory
leaks. Therefore, we should not rely on `backlogEventSentTbls` to determine
whether a `TableBucket` needs to report backlog completion. Instead, we should
check for the presence of the `TableBucket` in `backlogMarkedOffsets`; if it is
absent, the backlog has been processed.
Additionally, maintaining `onlySnapshotBuckets` is unnecessary, as
`backlogMarkedOffsets` provides sufficient state. We can trigger the backlog
event within `finishCurrentBoundedSplit()` by verifying whether the backlog
offset is less than or equal to `HybridSnapshotLogSplit#logStartingOffset`.
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/event/BacklogFinishEvent.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.fluss.flink.source.event;
+
+import org.apache.fluss.metadata.TableBucket;
+
+import org.apache.flink.api.connector.source.SourceEvent;
+
+import java.util.Objects;
+
+/**
+ * Event to signal that the backlog processing for a specific table bucket has
been completed. This
+ * event is sent from the source reader to the source enumerator to indicate
that all historical
+ * data (backlog) in the specified bucket has been processed.
+ */
+public class BacklogFinishEvent implements SourceEvent {
Review Comment:
nit: Rename to `FinishedBacklogEvent` to align other finished SourceEvent.
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/enumerator/FlinkSourceEnumerator.java:
##########
@@ -182,6 +188,8 @@ public class FlinkSourceEnumerator
@Nullable private final LakeSource<LakeSplit> lakeSource;
+ private final Map<TableBucket, Long> hasBacklogTbls;
Review Comment:
Please add Javadoc to this field to clarify the concept of backlog and
explain its specific purpose. Additionally, I recommend renaming the field to
`bucketsWithBacklogOffset` for improved clarity.
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/reader/FlinkSourceSplitReader.java:
##########
@@ -122,6 +128,25 @@ public FlinkSourceSplitReader(
@Nullable int[] projectedFields,
FlinkSourceReaderMetrics flinkSourceReaderMetrics,
@Nullable LakeSource<LakeSplit> lakeSource) {
+ this(
+ null,
Review Comment:
Refactor all usages of this constructor to explicitly pass the
`SourceReaderContext` instead of `null`. Relying on a null value introduces a
significant risk of potential NullPointerExceptions.
--
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]