[fix](tablet schedule) disable schedule need clear running tasks (#34461)
This commit is contained in:
@ -1572,7 +1572,7 @@ public class TabletScheduler extends MasterDaemon {
|
||||
releaseTabletCtx(tabletCtx, state, status == Status.UNRECOVERABLE);
|
||||
|
||||
// if check immediately, then no need to wait TabletChecker's 20s
|
||||
if (state == TabletSchedCtx.State.FINISHED) {
|
||||
if (state == TabletSchedCtx.State.FINISHED && !Config.disable_tablet_scheduler) {
|
||||
tryAddAfterFinished(tabletCtx);
|
||||
}
|
||||
}
|
||||
@ -1868,19 +1868,29 @@ public class TabletScheduler extends MasterDaemon {
|
||||
*/
|
||||
public void handleRunningTablets() {
|
||||
// 1. remove the tablet ctx if timeout
|
||||
List<TabletSchedCtx> timeoutTablets = Lists.newArrayList();
|
||||
List<TabletSchedCtx> cancelTablets = Lists.newArrayList();
|
||||
synchronized (this) {
|
||||
runningTablets.values().stream().filter(TabletSchedCtx::isTimeout).forEach(timeoutTablets::add);
|
||||
for (TabletSchedCtx tabletCtx : runningTablets.values()) {
|
||||
if (Config.disable_tablet_scheduler) {
|
||||
tabletCtx.setErrMsg("tablet scheduler is disabled");
|
||||
cancelTablets.add(tabletCtx);
|
||||
} else if (Config.disable_balance && tabletCtx.getType() == Type.BALANCE) {
|
||||
tabletCtx.setErrMsg("balance is disabled");
|
||||
cancelTablets.add(tabletCtx);
|
||||
} else if (tabletCtx.isTimeout()) {
|
||||
tabletCtx.setErrMsg("timeout");
|
||||
cancelTablets.add(tabletCtx);
|
||||
stat.counterCloneTaskTimeout.incrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. release ctx
|
||||
timeoutTablets.forEach(t -> {
|
||||
cancelTablets.forEach(t -> {
|
||||
// Set "resetReplicaState" to true because
|
||||
// the timeout task should also be considered as UNRECOVERABLE,
|
||||
// task should also be considered as UNRECOVERABLE,
|
||||
// so need to reset replica state.
|
||||
t.setErrMsg("timeout");
|
||||
finalizeTabletCtx(t, TabletSchedCtx.State.CANCELLED, Status.UNRECOVERABLE, "timeout");
|
||||
stat.counterCloneTaskTimeout.incrementAndGet();
|
||||
finalizeTabletCtx(t, TabletSchedCtx.State.CANCELLED, Status.UNRECOVERABLE, t.getErrMsg());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user