Skip to content

Commit

Permalink
[Enhancement] Support fe starting with only image no bdblog
Browse files Browse the repository at this point in the history
Signed-off-by: xiangguangyxg <[email protected]>
  • Loading branch information
xiangguangyxg committed Dec 30, 2024
1 parent fbc725c commit 2d92673
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ public static BDBEnvironment initBDBEnvironment(String nodeName) throws JournalE

// constructor
String selfNodeHostPort = NetUtils.getHostPortInAccessibleFormat(selfNode.first, selfNode.second);

boolean isFirstTimeStartUp = false;

File dbEnv = new File(getBdbDir());
if (!dbEnv.exists()) {
dbEnv.mkdirs();
isFirstTimeStartUp = true;
}

Pair<String, Integer> helperNode = GlobalStateMgr.getCurrentState().getNodeMgr().getHelperNode();
Expand All @@ -147,7 +149,7 @@ public static BDBEnvironment initBDBEnvironment(String nodeName) throws JournalE
helperHostPort, GlobalStateMgr.getCurrentState().isElectable());

// setup
bdbEnvironment.setup();
bdbEnvironment.setup(isFirstTimeStartUp);
return bdbEnvironment;
}

Expand All @@ -165,25 +167,27 @@ protected BDBEnvironment(File envHome, String selfNodeName, String selfNodeHostP
}

// The setup() method opens the environment and database
protected void setup() throws JournalException, InterruptedException {
protected void setup(boolean isFirstTimeStartUp) throws JournalException, InterruptedException {
this.closing = false;
ensureHelperInLocal();
initConfigs(isElectable);
initConfigs(isFirstTimeStartUp);
setupEnvironment();
}

protected void initConfigs(boolean isElectable) throws JournalException {
protected void initConfigs(boolean isFirstTimeStartUp) throws JournalException {
// Almost never used, just in case the master can not restart
if (Config.bdbje_reset_election_group) {
if (!isElectable) {
String errMsg = "Current node is not in the electable_nodes list. will exit";
LOG.error(errMsg);
throw new JournalException(errMsg);
}
DbResetRepGroup resetUtility = new DbResetRepGroup(envHome, STARROCKS_JOURNAL_GROUP, selfNodeName,
selfNodeHostPort);
resetUtility.reset();
LOG.info("group has been reset.");
if (!isFirstTimeStartUp) {
DbResetRepGroup resetUtility = new DbResetRepGroup(envHome, STARROCKS_JOURNAL_GROUP, selfNodeName,
selfNodeHostPort);
resetUtility.reset();
LOG.info("group has been reset.");
}
}

// set replication config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,16 +1265,7 @@ private void transferToLeader() {
dominationStartTimeMs = System.currentTimeMillis();

try {
// Log the first frontend
if (nodeMgr.isFirstTimeStartUp()) {
// if isFirstTimeStartUp is true, frontends must contain this Node.
Frontend self = nodeMgr.getMySelf();
Preconditions.checkNotNull(self);
// OP_ADD_FIRST_FRONTEND is emitted, so it can write to BDBJE even if canWrite is false
editLog.logAddFirstFrontend(self);
}

if (Config.bdbje_reset_election_group) {
if (Config.bdbje_reset_election_group || nodeMgr.isFirstTimeStartUp()) {
nodeMgr.resetFrontends();
}

Expand Down

0 comments on commit 2d92673

Please sign in to comment.