-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](fe) Skip decommissioning BE for stream load #65049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -519,13 +519,15 @@ public long getAvailableBeForTask(long jobId, long previousBeId) throws UserExce | |
| updateBeIdToMaxConcurrentTasks(); | ||
| Map<Long, Integer> beIdToConcurrentTasks = getBeCurrentTasksNumMap(); | ||
| int previousBeIdleTaskNum = 0; | ||
| boolean previousBeAvailable = false; | ||
|
|
||
| // 1. Find if the given BE id has more than half of available slots | ||
| if (previousBeId != -1L && availableBeIds.contains(previousBeId)) { | ||
| // get the previousBackend info | ||
| Backend previousBackend = Env.getCurrentSystemInfo().getBackend(previousBeId); | ||
| // check previousBackend is not null && load available | ||
| if (previousBackend != null && previousBackend.isLoadAvailable()) { | ||
| previousBeAvailable = true; | ||
| if (!beIdToMaxConcurrentTasks.containsKey(previousBeId)) { | ||
| previousBeIdleTaskNum = 0; | ||
| } else if (beIdToConcurrentTasks.containsKey(previousBeId)) { | ||
|
|
@@ -563,7 +565,7 @@ public long getAvailableBeForTask(long jobId, long previousBeId) throws UserExce | |
| } | ||
| // 4. on the basis of selecting the maximum idle slot be, | ||
| // try to reuse the object cache as much as possible | ||
| if (previousBeIdleTaskNum == maxIdleSlotNum) { | ||
| if (previousBeAvailable && previousBeIdleTaskNum == maxIdleSlotNum) { | ||
| return previousBeId; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still allows a saturated previous BE to be reused when the only idle capacity comes from a BE that the new availability filter excludes. The scheduler gate uses |
||
| } | ||
| return resultBeId; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ public class BeSelectionPolicy { | |
| public boolean needScheduleAvailable = false; | ||
| public boolean needQueryAvailable = false; | ||
| public boolean needLoadAvailable = false; | ||
| public boolean needNonDecommissioned = false; | ||
| // Resource tag. Empty means no need to consider resource tag. | ||
|
liaoxin01 marked this conversation as resolved.
|
||
| public Set<Tag> resourceTags = Sets.newHashSet(); | ||
| // storage medium. null means no need to consider storage medium. | ||
|
|
@@ -86,6 +87,12 @@ public Builder needQueryAvailable() { | |
|
|
||
| public Builder needLoadAvailable() { | ||
| policy.needLoadAvailable = true; | ||
| policy.needNonDecommissioned = true; | ||
| return this; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By making
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in ac51c3d: KafkaUtil.getInfoRequest() and KinesisUtil.getInfoRequest() now also skip Backend.isDecommissioning() metadata-proxy candidates, matching the non-decommissioned load-selection behavior. |
||
| } | ||
|
|
||
| public Builder needNonDecommissioned() { | ||
| policy.needNonDecommissioned = true; | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -156,6 +163,7 @@ private boolean isMatch(Backend backend) { | |
| if (needScheduleAvailable && !backend.isScheduleAvailable() | ||
| || needQueryAvailable && !backend.isQueryAvailable() | ||
| || needLoadAvailable && !backend.isLoadAvailable() | ||
| || needNonDecommissioned && (backend.isDecommissioned() || backend.isDecommissioning()) | ||
|
liaoxin01 marked this conversation as resolved.
|
||
| || (!resourceTags.isEmpty() && !resourceTags.contains(backend.getLocationTag())) | ||
|
liaoxin01 marked this conversation as resolved.
|
||
| || storageMedium != null && !backend.hasSpecifiedStorageMedium(storageMedium) | ||
| || (requireAliveBe && !backend.isAlive())) { | ||
|
|
@@ -231,8 +239,10 @@ public List<Backend> getCandidateBackends(Collection<Backend> backends) { | |
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.format("computeNode=%s | query=%s | load=%s | schedule=%s | tags=%s | medium=%s", | ||
| return String.format("computeNode=%s | query=%s | load=%s | schedule=%s | nonDecommissioned=%s" | ||
| + " | tags=%s | medium=%s", | ||
| preferComputeNode, needQueryAvailable, needLoadAvailable, needScheduleAvailable, | ||
| needNonDecommissioned, | ||
| resourceTags.stream().map(tag -> tag.toString()).collect(Collectors.joining(",")), storageMedium); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.doris.load; | ||
|
|
||
| import org.apache.doris.catalog.Env; | ||
| import org.apache.doris.cloud.system.CloudSystemInfoService; | ||
| import org.apache.doris.common.jmockit.Deencapsulation; | ||
| import org.apache.doris.system.Backend; | ||
| import org.apache.doris.system.SystemInfoService; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| public class StreamLoadHandlerTest { | ||
| @Test | ||
| public void testSelectBackendSkipsDecommissioningBackend() throws Exception { | ||
| SystemInfoService originalSystemInfoService = Env.getCurrentSystemInfo(); | ||
| Backend decommissioningBackend = createBackend(10001L, "127.0.0.1"); | ||
| decommissioningBackend.setDecommissioning(true); | ||
| Backend selectedBackend = createBackend(10002L, "127.0.0.2"); | ||
| CloudSystemInfoService systemInfoService = | ||
| new TestCloudSystemInfoService(Arrays.asList(decommissioningBackend, selectedBackend)); | ||
|
|
||
| try { | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", systemInfoService); | ||
|
|
||
| Assert.assertEquals(selectedBackend.getId(), StreamLoadHandler.selectBackend("cluster0").getId()); | ||
| } finally { | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", originalSystemInfoService); | ||
| } | ||
| } | ||
|
|
||
| private Backend createBackend(long id, String host) { | ||
| Backend backend = new Backend(id, host, 9050); | ||
| backend.setAlive(true); | ||
| return backend; | ||
| } | ||
|
|
||
| private static class TestCloudSystemInfoService extends CloudSystemInfoService { | ||
| private final List<Backend> backends; | ||
|
|
||
| private TestCloudSystemInfoService(List<Backend> backends) { | ||
| this.backends = backends; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Backend> getBackendsByClusterName(final String clusterName) { | ||
| return backends; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.doris.load.routineload; | ||
|
|
||
| import org.apache.doris.catalog.Env; | ||
| import org.apache.doris.cloud.load.CloudRoutineLoadManager; | ||
| import org.apache.doris.cloud.system.CloudSystemInfoService; | ||
| import org.apache.doris.common.Config; | ||
| import org.apache.doris.common.LoadException; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.common.jmockit.Deencapsulation; | ||
| import org.apache.doris.system.Backend; | ||
| import org.apache.doris.system.SystemInfoService; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class RoutineLoadBackendSelectionTest { | ||
| @Test | ||
| public void testAvailableBeForTaskDoesNotReuseDecommissioningPreviousBeWhenEligibleBesAreSaturated() | ||
| throws UserException { | ||
| int originalMaxRoutineLoadTaskNumPerBe = Config.max_routine_load_task_num_per_be; | ||
| SystemInfoService originalSystemInfoService = Env.getCurrentSystemInfo(); | ||
| Backend previousBackend = createBackend(10001L, "127.0.0.1"); | ||
| previousBackend.setDecommissioning(true); | ||
| Backend eligibleBackend = createBackend(10002L, "127.0.0.2"); | ||
| SystemInfoService systemInfoService = new SystemInfoService(); | ||
| systemInfoService.addBackend(previousBackend); | ||
| systemInfoService.addBackend(eligibleBackend); | ||
|
|
||
| try { | ||
| Config.max_routine_load_task_num_per_be = 0; | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", systemInfoService); | ||
| RoutineLoadManager routineLoadManager = new TestRoutineLoadManager( | ||
| Collections.singletonList(eligibleBackend.getId())); | ||
|
|
||
| Assert.assertEquals(-1L, routineLoadManager.getAvailableBeForTask(1L, previousBackend.getId())); | ||
| } finally { | ||
| Config.max_routine_load_task_num_per_be = originalMaxRoutineLoadTaskNumPerBe; | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", originalSystemInfoService); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCloudAvailableBackendIdsSkipsLoadDisabledBackend() throws Exception { | ||
| SystemInfoService originalSystemInfoService = Env.getCurrentSystemInfo(); | ||
| Backend loadDisabledBackend = createBackend(10001L, "127.0.0.1"); | ||
| loadDisabledBackend.setLoadDisabled(true); | ||
| Backend selectedBackend = createBackend(10002L, "127.0.0.2"); | ||
| CloudSystemInfoService systemInfoService = | ||
| new TestCloudSystemInfoService(Arrays.asList(loadDisabledBackend, selectedBackend)); | ||
| RoutineLoadJob routineLoadJob = Mockito.mock(RoutineLoadJob.class); | ||
| Mockito.when(routineLoadJob.getCloudCluster()).thenReturn("cluster0"); | ||
|
|
||
| try { | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", systemInfoService); | ||
| TestCloudRoutineLoadManager routineLoadManager = new TestCloudRoutineLoadManager(routineLoadJob); | ||
|
|
||
| Assert.assertEquals(Collections.singletonList(selectedBackend.getId()), | ||
| routineLoadManager.getAvailableBackendIdsForTest(1L)); | ||
| } finally { | ||
| Deencapsulation.setField(Env.getCurrentEnv(), "systemInfo", originalSystemInfoService); | ||
| } | ||
| } | ||
|
|
||
| private Backend createBackend(long id, String host) { | ||
| Backend backend = new Backend(id, host, 9050); | ||
| backend.setAlive(true); | ||
| return backend; | ||
| } | ||
|
|
||
| private static class TestRoutineLoadManager extends RoutineLoadManager { | ||
| private final List<Long> availableBackendIds; | ||
|
|
||
| private TestRoutineLoadManager(List<Long> availableBackendIds) { | ||
| this.availableBackendIds = availableBackendIds; | ||
| } | ||
|
|
||
| @Override | ||
| protected List<Long> getAvailableBackendIds(long jobId) { | ||
| return availableBackendIds; | ||
| } | ||
| } | ||
|
|
||
| private static class TestCloudRoutineLoadManager extends CloudRoutineLoadManager { | ||
| private final RoutineLoadJob routineLoadJob; | ||
|
|
||
| private TestCloudRoutineLoadManager(RoutineLoadJob routineLoadJob) { | ||
| this.routineLoadJob = routineLoadJob; | ||
| } | ||
|
|
||
| @Override | ||
| public RoutineLoadJob getJob(long jobId) { | ||
| return routineLoadJob; | ||
| } | ||
|
|
||
| private List<Long> getAvailableBackendIdsForTest(long jobId) throws LoadException { | ||
| return super.getAvailableBackendIds(jobId); | ||
| } | ||
| } | ||
|
|
||
| private static class TestCloudSystemInfoService extends CloudSystemInfoService { | ||
| private final List<Backend> backends; | ||
|
|
||
| private TestCloudSystemInfoService(List<Backend> backends) { | ||
| this.backends = backends; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Backend> getBackendsByClusterName(final String clusterName) { | ||
| return backends; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new primary predicate skips decommissioning BEs, but the fallback below still bypasses it when
backendIdsis empty. Lines 255-260 repopulate candidates fromroutineLoadManager.getBlacklist()with onlybackend != null, so a BE that was blacklisted by an earlier metadata retry and later enters decommissioning can still be selected here and receiveBackendServiceProxy.getInfoonce all primary candidates are filtered out.KinesisUtilhas the same fallback at lines 112-115. Please apply the same load-available/non-decommissioned predicate to the blacklist fallback, or share candidate construction, before sending metadata RPCs.