This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 259a9851f7 [core] Add compaction.force-wait to support force waiting
compaction finish when preparing commit (#5994)
259a9851f7 is described below
commit 259a9851f79f698bc3c390f5a0f74ac0489baf27
Author: yuzelin <[email protected]>
AuthorDate: Thu Jul 31 13:31:03 2025 +0800
[core] Add compaction.force-wait to support force waiting compaction finish
when preparing commit (#5994)
---
docs/layouts/shortcodes/generated/core_configuration.html | 6 ++++++
paimon-api/src/main/java/org/apache/paimon/CoreOptions.java | 13 ++++++++-----
.../src/test/java/org/apache/paimon/CoreOptionsTest.java | 7 +++++++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/docs/layouts/shortcodes/generated/core_configuration.html
b/docs/layouts/shortcodes/generated/core_configuration.html
index c287901335..09a7756877 100644
--- a/docs/layouts/shortcodes/generated/core_configuration.html
+++ b/docs/layouts/shortcodes/generated/core_configuration.html
@@ -230,6 +230,12 @@ under the License.
<td>Boolean</td>
<td>If set to true, compaction strategy will always include all
level 0 files in candidates.</td>
</tr>
+ <tr>
+ <td><h5>compaction.force-wait</h5></td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>If set to true, prepare commit will wait current compaction
finished.</td>
+ </tr>
<tr>
<td><h5>compaction.max-size-amplification-percent</h5></td>
<td style="word-wrap: break-word;">200</td>
diff --git a/paimon-api/src/main/java/org/apache/paimon/CoreOptions.java
b/paimon-api/src/main/java/org/apache/paimon/CoreOptions.java
index 54802731b4..eb36edf75f 100644
--- a/paimon-api/src/main/java/org/apache/paimon/CoreOptions.java
+++ b/paimon-api/src/main/java/org/apache/paimon/CoreOptions.java
@@ -682,6 +682,13 @@ public class CoreOptions implements Serializable {
.withDescription(
"If set to true, compaction strategy will always
include all level 0 files in candidates.");
+ public static final ConfigOption<Boolean> COMPACTION_FORCE_WAIT =
+ key("compaction.force-wait")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "If set to true, prepare commit will wait current
compaction finished.");
+
public static final ConfigOption<Integer> COMPACTION_SIZE_RATIO =
key("compaction.size-ratio")
.intType()
@@ -2896,11 +2903,7 @@ public class CoreOptions implements Serializable {
}
public boolean prepareCommitWaitCompaction() {
- if (!needLookup()) {
- return false;
- }
-
- return options.get(LOOKUP_WAIT);
+ return options.get(COMPACTION_FORCE_WAIT) || (needLookup() &&
options.get(LOOKUP_WAIT));
}
public LookupCompactMode lookupCompact() {
diff --git a/paimon-core/src/test/java/org/apache/paimon/CoreOptionsTest.java
b/paimon-core/src/test/java/org/apache/paimon/CoreOptionsTest.java
index bf5445fc10..44028c0ee0 100644
--- a/paimon-core/src/test/java/org/apache/paimon/CoreOptionsTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/CoreOptionsTest.java
@@ -72,6 +72,10 @@ public class CoreOptionsTest {
assertThat(options.prepareCommitWaitCompaction()).isFalse();
+ conf.set(CoreOptions.COMPACTION_FORCE_WAIT, true);
+ assertThat(options.prepareCommitWaitCompaction()).isTrue();
+ conf.remove(CoreOptions.COMPACTION_FORCE_WAIT.key());
+
conf.set(CoreOptions.DELETION_VECTORS_ENABLED, true);
assertThat(options.prepareCommitWaitCompaction()).isTrue();
conf.remove(CoreOptions.DELETION_VECTORS_ENABLED.key());
@@ -85,5 +89,8 @@ public class CoreOptionsTest {
conf.set(CoreOptions.LOOKUP_WAIT, false);
assertThat(options.prepareCommitWaitCompaction()).isFalse();
+
+ conf.set(CoreOptions.COMPACTION_FORCE_WAIT, true);
+ assertThat(options.prepareCommitWaitCompaction()).isTrue();
}
}