Skip to content

Commit 916286f

Browse files
authored
branch-4.0: [fix](fe) add --drop_backends param to start_fe.sh (#63306) (#63795)
pick #63306
1 parent f0f47d6 commit 916286f

5 files changed

Lines changed: 40 additions & 5 deletions

File tree

bin/start_fe.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OPTS="$(getopt \
3636
-l 'recovery_journal_id:' \
3737
-l 'console' \
3838
-l 'cluster_snapshot:' \
39+
-l 'drop_backends' \
3940
-- "$@")"
4041

4142
eval set -- "${OPTS}"
@@ -50,6 +51,7 @@ declare -a HELPER_ARGS=()
5051
declare -a METADATA_FAILURE_RECOVERY_ARGS=()
5152
declare -a RECOVERY_JOURNAL_ID_ARGS=()
5253
declare -a CLUSTER_SNAPSHOT_ARGS=()
54+
declare -a DROP_BACKENDS_ARGS=()
5355
while true; do
5456
case "$1" in
5557
--daemon)
@@ -85,6 +87,10 @@ while true; do
8587
CLUSTER_SNAPSHOT_ARGS=("--cluster_snapshot" "$2")
8688
shift 2
8789
;;
90+
--drop_backends)
91+
DROP_BACKENDS_ARGS=("--drop_backends")
92+
shift
93+
;;
8894
--)
8995
shift
9096
break
@@ -93,7 +99,7 @@ while true; do
9399
echo "Internal error"
94100
exit 1
95101
;;
96-
esac
102+
esac
97103
done
98104

99105
DORIS_HOME="$(
@@ -425,12 +431,12 @@ if [[ "${IMAGE_TOOL}" -eq 1 ]]; then
425431
echo "Internal error, USE IMAGE_TOOL like: ./start_fe.sh --image image_path"
426432
fi
427433
elif [[ "${RUN_DAEMON}" -eq 1 ]]; then
428-
nohup ${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" 2>&1 </dev/null &
434+
nohup ${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "${DROP_BACKENDS_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" 2>&1 </dev/null &
429435
elif [[ "${RUN_CONSOLE}" -eq 1 ]]; then
430436
export DORIS_LOG_TO_STDERR=1
431-
${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" ${OPT_VERSION:+${OPT_VERSION}} "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" </dev/null
437+
${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" ${OPT_VERSION:+${OPT_VERSION}} "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "${DROP_BACKENDS_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" </dev/null
432438
else
433-
${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" ${OPT_VERSION:+${OPT_VERSION}} "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" 2>&1 </dev/null
439+
${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" ${coverage_opt:+${coverage_opt}} org.apache.doris.DorisFE "${HELPER_ARGS[@]}" ${OPT_VERSION:+${OPT_VERSION}} "${METADATA_FAILURE_RECOVERY_ARGS[@]}" "${RECOVERY_JOURNAL_ID_ARGS[@]}" "${CLUSTER_SNAPSHOT_ARGS[@]}" "${DROP_BACKENDS_ARGS[@]}" "$@" >>"${STDOUT_LOGGER}" 2>&1 </dev/null
434440
fi
435441

436442
if [[ "${OPT_VERSION}" != "" ]]; then

docker/runtime/doris-compose/resource/init_fe.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ start_cloud_fe() {
119119
exit $MV_RES
120120
fi
121121
health_log "Recovery script executed and renamed to ${RECOVERY_SCRIPT}.bak"
122-
RECOVERY_ARGS="--metadata_failure_recovery --recovery_journal_id $JOURNAL_ID"
122+
RECOVERY_ARGS="--metadata_failure_recovery --recovery_journal_id $JOURNAL_ID --drop_backends"
123123
fi
124124

125125
if [ -f "$REGISTER_FILE" ] || [ -n "$RECOVERY_ARGS" ]; then

fe/fe-core/src/main/java/org/apache/doris/DorisFE.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ private static CommandLineOptions parseArgs(String[] args) {
350350
.desc("Specify the recovery truncate journal id, and journals greater than this id will be removed")
351351
.build());
352352
options.addOption("c", "cluster_snapshot", true, "Specify the cluster snapshot json file");
353+
options.addOption(Option.builder().longOpt(FeConstants.DROP_BACKENDS_KEY)
354+
.desc("When this FE becomes MASTER, drop all backends from cluster metadata (destructive)").build());
353355

354356
CommandLine cmd = null;
355357
try {
@@ -394,6 +396,9 @@ private static CommandLineOptions parseArgs(String[] args) {
394396
}
395397
System.setProperty(FeConstants.RECOVERY_JOURNAL_ID_KEY, recoveryJournalId.trim());
396398
}
399+
if (cmd.hasOption(FeConstants.DROP_BACKENDS_KEY)) {
400+
System.setProperty(FeConstants.DROP_BACKENDS_KEY, "true");
401+
}
397402
if (cmd.hasOption('b') || cmd.hasOption("bdb")) {
398403
if (cmd.hasOption('l') || cmd.hasOption("listdb")) {
399404
// list bdb je databases

fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.apache.doris.clone.TabletChecker;
5555
import org.apache.doris.clone.TabletScheduler;
5656
import org.apache.doris.clone.TabletSchedulerStat;
57+
import org.apache.doris.cloud.system.CloudSystemInfoService;
5758
import org.apache.doris.common.AnalysisException;
5859
import org.apache.doris.common.Config;
5960
import org.apache.doris.common.ConfigBase;
@@ -260,6 +261,7 @@
260261
import org.apache.doris.statistics.StatisticsJobAppender;
261262
import org.apache.doris.statistics.StatisticsMetricCollector;
262263
import org.apache.doris.statistics.query.QueryStats;
264+
import org.apache.doris.system.Backend;
263265
import org.apache.doris.system.Frontend;
264266
import org.apache.doris.system.HeartbeatMgr;
265267
import org.apache.doris.system.SystemInfoService;
@@ -315,6 +317,7 @@
315317
import java.util.ArrayList;
316318
import java.util.Arrays;
317319
import java.util.Collection;
320+
import java.util.Collections;
318321
import java.util.Comparator;
319322
import java.util.HashMap;
320323
import java.util.HashSet;
@@ -1766,6 +1769,26 @@ private void transferToMaster() {
17661769
editLog.logMasterInfo(masterInfo);
17671770
LOG.info("logMasterInfo:{}", masterInfo);
17681771

1772+
if (Boolean.getBoolean(FeConstants.DROP_BACKENDS_KEY)) {
1773+
LOG.info("drop_backends is set, dropping all backends...");
1774+
try {
1775+
SystemInfoService systemInfoService = Env.getCurrentSystemInfo();
1776+
List<Backend> bes = systemInfoService.getAllClusterBackendsNoException().values()
1777+
.stream().collect(Collectors.toList());
1778+
if (Config.isNotCloudMode()) {
1779+
for (Backend be : bes) {
1780+
systemInfoService.dropBackend(be.getHost(), be.getHeartbeatPort());
1781+
}
1782+
} else {
1783+
((CloudSystemInfoService) systemInfoService).updateCloudBackends(Collections.emptyList(), bes);
1784+
}
1785+
} catch (Exception e) {
1786+
LOG.warn("failed to drop backends", e);
1787+
}
1788+
System.clearProperty(FeConstants.DROP_BACKENDS_KEY);
1789+
LOG.info("finished dropping all backends");
1790+
}
1791+
17691792
// for master, the 'isReady' is set behind.
17701793
// but we are sure that all metadata is replayed if we get here.
17711794
// so no need to check 'isReady' flag in this method

fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ public class FeConstants {
6868

6969
public static String METADATA_FAILURE_RECOVERY_KEY = "metadata_failure_recovery";
7070
public static String RECOVERY_JOURNAL_ID_KEY = "recovery_journal_id";
71+
public static String DROP_BACKENDS_KEY = "drop_backends";
7172
}

0 commit comments

Comments
 (0)