Skip to content
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

branch-2.0: [fix](create table) fix create table fail msg #45623 #45653

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ private RootPathLoadStatistic chooseAvailableDestPath(TabletSchedCtx tabletCtx,
!allFitPathsSameMedium.isEmpty() ? allFitPathsSameMedium : allFitPathsDiffMedium;
if (allFitPaths.isEmpty()) {
List<String> backendsInfo = Env.getCurrentSystemInfo().getAllBackends().stream()
.filter(be -> be.getLocationTag() == tag)
.filter(be -> be.getLocationTag().equals(tag))
.map(Backend::getDetailsForCreateReplica)
.collect(Collectors.toList());
throw new SchedException(Status.UNRECOVERABLE, String.format("unable to find dest path for new replica"
Expand Down
3 changes: 3 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.doris.common.util.PrintableMap;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.qe.SimpleScheduler;
import org.apache.doris.resource.Tag;
import org.apache.doris.system.HeartbeatResponse.HbStatus;
import org.apache.doris.thrift.TDisk;
Expand Down Expand Up @@ -270,6 +271,8 @@ public String getDetailsForCreateReplica() {
sb.append(", isDecommissioned=true, exclude it");
} else if (isComputeNode()) {
sb.append(", isComputeNode=true, exclude it");
} else if (!Config.disable_backend_black_list && !SimpleScheduler.isAvailable(this)) {
sb.append(", is in black list, exclude it");
} else {
sb.append(", hdd disks count={");
if (hddOk > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public String getDetailsForCreateReplica(ReplicaAllocation replicaAlloc) {
StringBuilder sb = new StringBuilder(" Backends details: ");
for (Tag tag : replicaAlloc.getAllocMap().keySet()) {
sb.append("backends with tag ").append(tag).append(" is ");
sb.append(idToBackendRef.values().stream().filter(be -> be.getLocationTag() == tag)
sb.append(idToBackendRef.values().stream().filter(be -> be.getLocationTag().equals(tag))
.map(Backend::getDetailsForCreateReplica)
.collect(Collectors.toList()));
sb.append(", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
import org.apache.doris.common.ExceptionChecker;
import org.apache.doris.common.UserException;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.resource.Tag;
import org.apache.doris.utframe.UtFrameUtils;

import com.google.common.collect.Maps;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -783,4 +786,19 @@ public void testCreateTableWithForceReplica() throws DdlException {
Assert.assertEquals(1, tb.getPartitionInfo().getReplicaAllocation(p1.getId()).getTotalReplicaNum());
Assert.assertEquals(1, tb.getTableProperty().getReplicaAllocation().getTotalReplicaNum());
}

@Test
public void testCreateTableDetailMsg() throws Exception {
Map<Tag, Short> allocMap = Maps.newHashMap();
allocMap.put(Tag.create(Tag.TYPE_LOCATION, "group_a"), (short) 6);
Assert.assertEquals(" Backends details: backends with tag {\"location\" : \"group_a\"} is [], ",
Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation(allocMap)));

allocMap.clear();
allocMap.put(Tag.create(Tag.TYPE_LOCATION, new String(Tag.VALUE_DEFAULT_TAG)), (short) 6);
String msg = Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation(allocMap));
Assert.assertTrue("msg: " + msg, msg.contains("Backends details: backends with tag {\"location\" : \"default\"} is [[backendId=")
&& msg.contains("hdd disks count={ok=1,}, ssd disk count={}]"));
}

}
Loading