Skip to content

Commit 10eac22

Browse files
authored
[chore](conf) Set enable_advance_next_id=true by default (#44790)
Bind the generation of next_id to physical time to ensure its generation is monotonically increasing, even if we directly overwrite the FE metadata and then restart. This way, it supports a lossy cluster rollback in scenarios where major version upgrades are incompatible.
1 parent 7b45bc3 commit 10eac22

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

fe/fe-common/src/main/java/org/apache/doris/common/Config.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@ public class Config extends ConfigBase {
29572957
"Whether to advance the ID generator after becoming Master to ensure that the id "
29582958
+ "generator will not be rolled back even when metadata is rolled back."
29592959
})
2960-
public static boolean enable_advance_next_id = false;
2960+
public static boolean enable_advance_next_id = true;
29612961

29622962
// The count threshold to do manual GC when doing checkpoint but not enough memory.
29632963
// Set zero to disable it.

fe/fe-core/src/test/java/org/apache/doris/analysis/ExportToOutfileLogicalPlanTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.doris.analysis;
1919

20+
import org.apache.doris.common.Config;
2021
import org.apache.doris.common.FeConstants;
2122
import org.apache.doris.common.UserException;
2223
import org.apache.doris.load.ExportJob;
@@ -47,6 +48,12 @@ public class ExportToOutfileLogicalPlanTest extends TestWithFeService {
4748
private String dbName = "testDb";
4849
private String tblName = "table1";
4950

51+
private final boolean defaultEnableAdvanceNextId = Config.enable_advance_next_id; // backup
52+
53+
{
54+
enableAdvanceNextId = false;
55+
}
56+
5057
/**
5158
* create a database and a table
5259
*
@@ -65,6 +72,7 @@ protected void runBeforeAll() throws Exception {
6572
+ "PARTITION p4 VALUES LESS THAN (\"50\")\n" + ")\n"
6673
+ " distributed by hash(k1) buckets 10\n"
6774
+ "properties(\"replication_num\" = \"1\");");
75+
Config.enable_advance_next_id = defaultEnableAdvanceNextId; // restore
6876
}
6977

7078
/**

fe/fe-core/src/test/java/org/apache/doris/common/proc/IndexesProcNodeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testFetchResult() throws AnalysisException {
9696
Assert.assertEquals(procResult.getRows().get(3).get(5), "col_4");
9797
Assert.assertEquals(procResult.getRows().get(3).get(11), "NGRAM_BF");
9898
Assert.assertEquals(procResult.getRows().get(3).get(12), "ngram_bf index on col_4");
99-
Assert.assertEquals(procResult.getRows().get(3).get(13), "(\"gram_size\" = \"3\", \"bf_size\" = \"256\")");
99+
Assert.assertEquals(procResult.getRows().get(3).get(13), "(\"bf_size\" = \"256\", \"gram_size\" = \"3\")");
100100

101101
}
102102
}

fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.junit.rules.ExpectedException;
5656

5757
import java.util.ArrayList;
58+
import java.util.Arrays;
5859
import java.util.HashMap;
5960
import java.util.List;
6061
import java.util.UUID;
@@ -231,8 +232,10 @@ public void testGetDBNames() throws Exception {
231232
TGetDbsResult dbNames = impl.getDbNames(params);
232233

233234
Assert.assertEquals(dbNames.getDbs().size(), 2);
234-
Assert.assertTrue(dbNames.getDbs().contains("test"));
235-
Assert.assertTrue(dbNames.getDbs().contains("test_"));
235+
List<String> expected = Arrays.asList("test", "test_");
236+
dbNames.getDbs().sort(String::compareTo);
237+
expected.sort(String::compareTo);
238+
Assert.assertEquals(dbNames.getDbs(), expected);
236239
}
237240

238241
@Test

fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public abstract class TestWithFeService {
140140
protected ConnectContext connectContext;
141141
protected boolean needCleanDir = true;
142142
protected int lastFeRpcPort = 0;
143+
// make it default to enable_advance_next_id
144+
protected boolean enableAdvanceNextId = Config.enable_advance_next_id;
143145

144146
protected static final String DEFAULT_CLUSTER_PREFIX = "";
145147

@@ -152,6 +154,8 @@ public Set<Integer> getEnableNereidsRules() {
152154

153155
@BeforeAll
154156
public final void beforeAll() throws Exception {
157+
// this.enableAdvanceNextId may be reset by children classes
158+
Config.enable_advance_next_id = this.enableAdvanceNextId;
155159
FeConstants.enableInternalSchemaDb = false;
156160
FeConstants.shouldCreateInternalWorkloadGroup = false;
157161
beforeCreatingConnectContext();

0 commit comments

Comments
 (0)