Skip to content

Commit a94a7c4

Browse files
mymeiyimorningman
authored andcommitted
[fix](group commit) group commit select backend should consider isLoadAvailable (#61555)
1. extracts backend availability checks into a shared isBackendAvailable() method 2. adds the missing isLoadAvailable() check to group commit backend selection. Previously, backends with isLoadDisabled=true or isShutDown=true could still be selected for group commit, which is incorrect.
1 parent d730396 commit a94a7c4

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,7 @@ private Long getCachedBackend(String cluster, long tableId) {
357357
return null;
358358
}
359359
Backend backend = Env.getCurrentSystemInfo().getBackend(backendId);
360-
if (backend != null && backend.isAlive() && !backend.isDecommissioned()
361-
&& (!Config.isCloudMode() || !backend.isDecommissioning())
362-
&& (!Config.isCloudMode() || cluster == null
363-
|| cluster.equals(backend.getCloudClusterName()))) {
360+
if (isBackendAvailable(backend, cluster)) {
364361
return backend.getId();
365362
} else {
366363
tableToBeMap.remove(encode(cluster, tableId));
@@ -372,13 +369,26 @@ private Long getCachedBackend(String cluster, long tableId) {
372369
return null;
373370
}
374371

372+
private boolean isBackendAvailable(Backend backend, String cluster) {
373+
if (backend == null || !backend.isAlive() || backend.isDecommissioned() || !backend.isLoadAvailable()) {
374+
return false;
375+
}
376+
if (!Config.isCloudMode()) {
377+
return true;
378+
}
379+
// for cloud mode
380+
if (backend.isDecommissioning()) {
381+
return false;
382+
}
383+
return cluster == null || cluster.equals(backend.getCloudClusterName());
384+
}
385+
375386
@Nullable
376387
private Long getRandomBackend(String cluster, long tableId, List<Backend> backends) {
377388
OlapTable table = (OlapTable) Env.getCurrentEnv().getInternalCatalog().getTableByTableId(tableId);
378389
Collections.shuffle(backends);
379390
for (Backend backend : backends) {
380-
if (backend.isAlive() && !backend.isDecommissioned() && (!Config.isCloudMode()
381-
|| !backend.isDecommissioning())) {
391+
if (isBackendAvailable(backend, cluster)) {
382392
tableToBeMap.put(encode(cluster, tableId), backend.getId());
383393
tableToPressureMap.put(tableId,
384394
new SlidingWindowCounter(table.getGroupCommitIntervalMs() / 1000 + 1));

0 commit comments

Comments
 (0)