Code review comment: how followers recover default warehouse?

Code before review:
private void transferToLeader() {
FrontendNodeType oldType = feType;
if (replayer != null) {
replayer.setStop();
try {
replayer.join();
} catch (InterruptedException e) {
LOG.warn("got exception when stopping the replayer thread", e);
}
replayer = null;
}
isReady.set(false);
try {
journal.open();
if (!haProtocol.fencing()) {
throw new Exception("fencing failed. will exit");
}
long maxJournalId = journal.getMaxJournalId();
replayJournal(maxJournalId);
nodeMgr.checkCurrentNodeExist();
journalWriter.init(maxJournalId);
} catch (Exception e) {
LOG.error("failed to init journal after transfer to leader! will exit", e);
System.exit(-1);
}
journalWriter.startDaemon();
feType = FrontendNodeType.LEADER;
try {
int starrocksMetaVersion = MetaContext.get().getStarRocksMetaVersion();
if (starrocksMetaVersion < FeConstants.STARROCKS_META_VERSION) {
editLog.logMetaVersion(new MetaVersion(FeConstants.STARROCKS_META_VERSION));
MetaContext.get().setStarRocksMetaVersion(FeConstants.STARROCKS_META_VERSION);
}
if (nodeMgr.isFirstTimeStartUp()) {
Frontend self = nodeMgr.getMySelf();
Preconditions.checkNotNull(self);
editLog.logAddFirstFrontend(self);
}
if (!isDefaultClusterCreated) {
initDefaultCluster();
}
nodeMgr.setLeaderInfo();
if (USING_NEW_PRIVILEGE) {
if (needUpgradedToNewPrivilege()) {
reInitializeNewPrivilegeOnUpgrade();
AuthUpgrader upgrader = new AuthUpgrader(auth, authenticationManager, authorizationManager, this);
upgrader.upgradeAsLeader();
this.domainResolver.setAuthenticationManager(authenticationManager);
}
LOG.info("set usingNewPrivilege to true after transfer to leader");
usingNewPrivilege.set(true);
auth = null;
}
startLeaderOnlyDaemonThreads();
startAllNodeTypeDaemonThreads();
insertOverwriteJobManager.cancelRunningJobs();
if (!isDefaultWarehouseCreated) {
initDefaultWarehouse();
}
updateDefaultWarehouse();
MetricRepo.init();
isReady.set(true);
String msg = "leader finished to replay journal, can write now.";
Util.stdoutWithTime(msg);
LOG.info(msg);
ThreadPoolManager.registerAllThreadPoolMetric();
if (nodeMgr.isFirstTimeStartUp()) {
VariableMgr.setSystemVariable(VariableMgr.getDefaultSessionVariable(), new SystemVariable(SetType.GLOBAL,
SessionVariable.ENABLE_ADAPTIVE_SINK_DOP,
LiteralExpr.create("true", Type.BOOLEAN)),
false);
}
} catch (UserException e) {
LOG.warn("Failed to set ENABLE_ADAPTIVE_SINK_DOP", e);
} catch (Throwable t) {
LOG.warn("transfer to leader failed with error", t);
feType = oldType;
throw t;
}
}

Line under review: updateDefaultWarehouse();

Code after addressing the review:
private void transferToLeader() {
FrontendNodeType oldType = feType;
if (replayer != null) {
replayer.setStop();
try {
replayer.join();
} catch (InterruptedException e) {
LOG.warn("got exception when stopping the replayer thread", e);
}
replayer = null;
}
isReady.set(false);
try {
journal.open();
if (!haProtocol.fencing()) {
throw new Exception("fencing failed. will exit");
}
long maxJournalId = journal.getMaxJournalId();
replayJournal(maxJournalId);
nodeMgr.checkCurrentNodeExist();
journalWriter.init(maxJournalId);
} catch (Exception e) {
LOG.error("failed to init journal after transfer to leader! will exit", e);
System.exit(-1);
}
journalWriter.startDaemon();
feType = FrontendNodeType.LEADER;
try {
int starrocksMetaVersion = MetaContext.get().getStarRocksMetaVersion();
if (starrocksMetaVersion < FeConstants.STARROCKS_META_VERSION) {
editLog.logMetaVersion(new MetaVersion(FeConstants.STARROCKS_META_VERSION));
MetaContext.get().setStarRocksMetaVersion(FeConstants.STARROCKS_META_VERSION);
}
if (nodeMgr.isFirstTimeStartUp()) {
Frontend self = nodeMgr.getMySelf();
Preconditions.checkNotNull(self);
editLog.logAddFirstFrontend(self);
}
if (!isDefaultClusterCreated) {
initDefaultCluster();
}
nodeMgr.setLeaderInfo();
if (USING_NEW_PRIVILEGE) {
if (needUpgradedToNewPrivilege()) {
reInitializeNewPrivilegeOnUpgrade();
AuthUpgrader upgrader = new AuthUpgrader(auth, authenticationManager, authorizationManager, this);
upgrader.upgradeAsLeader();
this.domainResolver.setAuthenticationManager(authenticationManager);
}
LOG.info("set usingNewPrivilege to true after transfer to leader");
usingNewPrivilege.set(true);
auth = null;
}
startLeaderOnlyDaemonThreads();
startAllNodeTypeDaemonThreads();
insertOverwriteJobManager.cancelRunningJobs();
if (!isDefaultWarehouseCreated) {
initDefaultWarehouse();
}
updateDefaultWarehouse();
MetricRepo.init();
isReady.set(true);
String msg = "leader finished to replay journal, can write now.";
Util.stdoutWithTime(msg);
LOG.info(msg);
ThreadPoolManager.registerAllThreadPoolMetric();
if (nodeMgr.isFirstTimeStartUp()) {
VariableMgr.setSystemVariable(VariableMgr.getDefaultSessionVariable(), new SystemVariable(SetType.GLOBAL,
SessionVariable.ENABLE_ADAPTIVE_SINK_DOP,
LiteralExpr.create("true", Type.BOOLEAN)),
false);
}
} catch (UserException e) {
LOG.warn("Failed to set ENABLE_ADAPTIVE_SINK_DOP", e);
} catch (Throwable t) {
LOG.warn("transfer to leader failed with error", t);
feType = oldType;
throw t;
}
}