Skip to content

Commit 9443e31

Browse files
authored
[opt](load) disable enable_strict_consistency_dml by default in cloud mode (#61814)
## Problem `enable_strict_consistency_dml` is designed to handle multi-replica consistency for DML operations. In cloud mode (store-compute separation), data has only a single copy, so there is no multi-replica consistency concern. Keeping this variable `true` in cloud mode causes unnecessary data shuffling overhead. ## Solution Override `isEnableStrictConsistencyDml()` to return `false` when running in cloud mode (`Config.isCloudMode()`), regardless of the session variable's value. This follows the same pattern as `isDisableFileCache()`. Update all call sites in `RequestPropertyDeriver` to use the getter instead of direct field access so the cloud-mode check takes effect. ## Tests Added two unit tests in `SessionVariablesTest`: - Verify `isEnableStrictConsistencyDml()` returns `false` in cloud mode (even when field is `true`) - Verify `isEnableStrictConsistencyDml()` follows the field value in non-cloud mode
1 parent 4312232 commit 9443e31

4 files changed

Lines changed: 52 additions & 7 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public Void visitPhysicalBlackholeSink(PhysicalBlackholeSink<? extends Plan> sin
148148

149149
@Override
150150
public Void visitPhysicalOlapTableSink(PhysicalOlapTableSink<? extends Plan> olapTableSink, PlanContext context) {
151-
if (connectContext != null && !connectContext.getSessionVariable().enableStrictConsistencyDml) {
151+
if (connectContext != null && !connectContext.getSessionVariable().isEnableStrictConsistencyDml()) {
152152
addRequestPropertyToChildren(PhysicalProperties.ANY);
153153
} else {
154154
addRequestPropertyToChildren(olapTableSink.getRequirePhysicalProperties());
@@ -158,7 +158,7 @@ public Void visitPhysicalOlapTableSink(PhysicalOlapTableSink<? extends Plan> ola
158158

159159
@Override
160160
public Void visitPhysicalHiveTableSink(PhysicalHiveTableSink<? extends Plan> hiveTableSink, PlanContext context) {
161-
if (connectContext != null && !connectContext.getSessionVariable().enableStrictConsistencyDml) {
161+
if (connectContext != null && !connectContext.getSessionVariable().isEnableStrictConsistencyDml()) {
162162
addRequestPropertyToChildren(PhysicalProperties.ANY);
163163
} else {
164164
addRequestPropertyToChildren(hiveTableSink.getRequirePhysicalProperties());
@@ -169,7 +169,7 @@ public Void visitPhysicalHiveTableSink(PhysicalHiveTableSink<? extends Plan> hiv
169169
@Override
170170
public Void visitPhysicalIcebergTableSink(
171171
PhysicalIcebergTableSink<? extends Plan> icebergTableSink, PlanContext context) {
172-
if (connectContext != null && !connectContext.getSessionVariable().enableStrictConsistencyDml) {
172+
if (connectContext != null && !connectContext.getSessionVariable().isEnableStrictConsistencyDml()) {
173173
addRequestPropertyToChildren(PhysicalProperties.ANY);
174174
} else {
175175
addRequestPropertyToChildren(icebergTableSink.getRequirePhysicalProperties());
@@ -180,7 +180,7 @@ public Void visitPhysicalIcebergTableSink(
180180
@Override
181181
public Void visitPhysicalMaxComputeTableSink(
182182
PhysicalMaxComputeTableSink<? extends Plan> mcTableSink, PlanContext context) {
183-
if (connectContext != null && !connectContext.getSessionVariable().enableStrictConsistencyDml) {
183+
if (connectContext != null && !connectContext.getSessionVariable().isEnableStrictConsistencyDml()) {
184184
addRequestPropertyToChildren(PhysicalProperties.ANY);
185185
} else {
186186
addRequestPropertyToChildren(mcTableSink.getRequirePhysicalProperties());

fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5779,6 +5779,11 @@ public void setDumpNereidsMemo(boolean dumpNereidsMemo) {
57795779
}
57805780

57815781
public boolean isEnableStrictConsistencyDml() {
5782+
// In cloud mode (store-compute separation), there is only a single copy of data,
5783+
// so multi-replica consistency is not a concern. Default to false.
5784+
if (Config.isCloudMode()) {
5785+
return false;
5786+
}
57825787
return this.enableStrictConsistencyDml;
57835788
}
57845789

fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariablesTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
package org.apache.doris.qe;
1919

20+
import org.apache.doris.common.Config;
2021
import org.apache.doris.common.FeConstants;
2122
import org.apache.doris.nereids.parser.NereidsParser;
2223
import org.apache.doris.utframe.TestWithFeService;
2324

25+
import mockit.Mock;
26+
import mockit.MockUp;
2427
import org.junit.jupiter.api.Assertions;
2528
import org.junit.jupiter.api.Test;
2629

@@ -136,4 +139,37 @@ public void testMorValuePredicatePushdownEnabled() {
136139
Assertions.assertTrue(sv.isMorValuePredicatePushdownEnabled("db1", "tbl1"));
137140
Assertions.assertFalse(sv.isMorValuePredicatePushdownEnabled("db2", "tbl1"));
138141
}
142+
143+
@Test
144+
public void testEnableStrictConsistencyDmlDefaultsToFalseInCloudMode() {
145+
new MockUp<Config>() {
146+
@Mock
147+
public boolean isCloudMode() {
148+
return true;
149+
}
150+
};
151+
SessionVariable sv = new SessionVariable();
152+
// In cloud mode, enable_strict_consistency_dml should always return false
153+
// because store-compute separation has no multi-replica consistency concern.
154+
Assertions.assertFalse(sv.isEnableStrictConsistencyDml());
155+
// Even if the field is set to true, cloud mode overrides it.
156+
sv.enableStrictConsistencyDml = true;
157+
Assertions.assertFalse(sv.isEnableStrictConsistencyDml());
158+
}
159+
160+
@Test
161+
public void testEnableStrictConsistencyDmlDefaultsTrueInNonCloudMode() {
162+
new MockUp<Config>() {
163+
@Mock
164+
public boolean isCloudMode() {
165+
return false;
166+
}
167+
};
168+
SessionVariable sv = new SessionVariable();
169+
// In non-cloud mode, default is true (multi-replica consistency is needed).
170+
Assertions.assertTrue(sv.isEnableStrictConsistencyDml());
171+
// Users can disable it.
172+
sv.enableStrictConsistencyDml = false;
173+
Assertions.assertFalse(sv.isEnableStrictConsistencyDml());
174+
}
139175
}

regression-test/suites/insert_p0/test_insert_tablet_sink.groovy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ suite("test_insert_tablet_sink") {
6060

6161

6262
sql """ insert into table_largeint select k1,c_varchar,cast(rand() * 50000000 as bigint) from tmp_varchar where k1>=3; """
63-
explain {
64-
sql "insert into table_largeint select k1,c_varchar,cast(rand() * 50000000 as bigint) from tmp_varchar;"
65-
contains "OLAP_TABLE_SINK_HASH_PARTITIONED"
63+
// In cloud mode (store-compute separation), enable_strict_consistency_dml defaults to false,
64+
// so no hash-partitioned sink is required for multi-replica consistency.
65+
if (!isCloudMode()) {
66+
explain {
67+
sql "insert into table_largeint select k1,c_varchar,cast(rand() * 50000000 as bigint) from tmp_varchar;"
68+
contains "OLAP_TABLE_SINK_HASH_PARTITIONED"
69+
}
6670
}
6771

6872
sql """ insert into table_largeint select k1,c_varchar,cast(rand() * 50000000 as bigint) from tmp_varchar; """

0 commit comments

Comments
 (0)