leaves12138 commented on code in PR #8857:
URL: https://github.com/apache/paimon/pull/8857#discussion_r3655996774


##########
paimon-common/src/main/java/org/apache/paimon/lookup/sort/db/AsyncLsmCompactor.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.paimon.lookup.sort.db;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+/** Coordinates asynchronous compaction, failure propagation, backpressure, 
and shutdown. */
+class AsyncLsmCompactor extends LsmCompactor {
+
+    private final ExecutorService executor;
+
+    @Nullable private Future<?> compactionFuture;
+
+    AsyncLsmCompactor(
+            LsmLevels levels,
+            CompactorFactory compactorFactory,
+            int levelZeroFileCountTrigger,
+            UniversalCompactor.FileSupplier fileSupplier,
+            UniversalCompactor.FileDeleter fileDeleter,
+            ExecutorService executor) {
+        super(levels, compactorFactory, levelZeroFileCountTrigger, 
fileSupplier, fileDeleter);
+        this.executor = executor;
+    }
+
+    @Override
+    void scheduleIfNeeded() throws IOException {
+        checkFailure();
+        if (!needsCompaction() || compactionFuture != null) {

Review Comment:
   After tracing the supported single-foreground-thread usage, the practical 
impact is much narrower than I stated above. Once the worker's final check sees 
fewer than `trigger` L0 files, only one foreground flush can occur before its 
own `scheduleIfNeeded()` call, so the count can reach at most `trigger`, not 
the `2 * trigger` backpressure threshold. Reads remain correct, and the next 
flush will clear the completed future and schedule compaction; if this happens 
during close, the local DB is ending its lifecycle anyway.
   
   Therefore this is only a narrow delayed-compaction/performance case (up to 
the trigger-sized L0 set remaining until the next flush), not a correctness or 
backpressure issue. Please disregard the backpressure claim; I do not consider 
this blocking.



-- 
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]

Reply via email to