This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new eb958ad0f22 [improvement](create table) add backend details to creating table failed msg #41463 (#42049) eb958ad0f22 is described below commit eb958ad0f22bf3e9ff2030132d67f4f6085bd8f9 Author: yujun <yu.jun.re...@gmail.com> AuthorDate: Sun Oct 20 10:41:10 2024 +0800 [improvement](create table) add backend details to creating table failed msg #41463 (#42049) cherry pick from #41463 --- .../doris/common/util/DynamicPartitionUtil.java | 3 +- .../main/java/org/apache/doris/system/Backend.java | 65 ++++++++++++++++++++++ .../org/apache/doris/system/SystemInfoService.java | 14 ++++- .../org/apache/doris/catalog/CreateTableTest.java | 6 +- .../apache/doris/catalog/ModifyBackendTest.java | 9 ++- .../trees/plans/CreateTableCommandTest.java | 5 +- 6 files changed, 95 insertions(+), 7 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java index 7fc13392cef..a713df0427f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java @@ -258,7 +258,8 @@ public class DynamicPartitionUtil { } catch (DdlException e) { throw new DdlException("Failed to find enough backend for ssd storage medium. When setting " + DynamicPartitionProperty.HOT_PARTITION_NUM + " > 0, the hot partitions will store " - + "in ssd. Please check the replication num,replication tag and storage medium."); + + "in ssd. Please check the replication num,replication tag and storage medium." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(replicaAlloc)); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java b/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java index 93a8ecdec6a..b0304648b73 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java +++ b/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java @@ -300,6 +300,71 @@ public class Backend implements Writable { return this.backendStatus.currentFragmentNum; } + public String getDetailsForCreateReplica() { + int hddBad = 0; + int hddExceedLimit = 0; + int hddOk = 0; + int ssdBad = 0; + int ssdExceedLimit = 0; + int ssdOk = 0; + for (DiskInfo disk : disksRef.values()) { + TStorageMedium storageMedium = disk.getStorageMedium(); + if (storageMedium == TStorageMedium.HDD) { + if (!disk.isAlive()) { + hddBad++; + } else if (disk.exceedLimit(true)) { + hddExceedLimit++; + } else { + hddOk++; + } + } else if (storageMedium == TStorageMedium.SSD) { + if (!disk.isAlive()) { + ssdBad++; + } else if (disk.exceedLimit(true)) { + ssdExceedLimit++; + } else { + ssdOk++; + } + } + } + + StringBuilder sb = new StringBuilder("["); + sb.append("backendId=").append(id); + sb.append(", host=").append(host); + if (!isAlive()) { + sb.append(", isAlive=false, exclude it"); + } else if (isDecommissioned()) { + sb.append(", isDecommissioned=true, exclude it"); + } else if (isComputeNode()) { + sb.append(", isComputeNode=true, exclude it"); + } else { + sb.append(", hdd disks count={"); + if (hddOk > 0) { + sb.append("ok=").append(hddOk).append(","); + } + if (hddBad > 0) { + sb.append("bad=").append(hddBad).append(","); + } + if (hddExceedLimit > 0) { + sb.append("capExceedLimit=").append(hddExceedLimit).append(","); + } + sb.append("}, ssd disk count={"); + if (ssdOk > 0) { + sb.append("ok=").append(ssdOk).append(","); + } + if (ssdBad > 0) { + sb.append("bad=").append(ssdBad).append(","); + } + if (ssdExceedLimit > 0) { + sb.append("capExceedLimit=").append(ssdExceedLimit).append(","); + } + sb.append("}"); + } + sb.append("]"); + + return sb.toString(); + } + // for test only public void updateOnce(int bePort, int httpPort, int beRpcPort) { if (this.bePort != bePort) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java index 9d26eb3edf6..69216dd4d13 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java +++ b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java @@ -543,7 +543,7 @@ public class SystemInfoService { String failedMsg = Joiner.on("\n").join(failedEntries); throw new DdlException("Failed to find enough backend, please check the replication num," + "replication tag and storage medium and avail capacity of backends " - + "or maybe all be on same host.\n" + + "or maybe all be on same host." + getDetailsForCreateReplica(replicaAlloc) + "\n" + "Create failed replications:\n" + failedMsg); } } @@ -552,6 +552,18 @@ public class SystemInfoService { return Pair.of(chosenBackendIds, storageMedium); } + 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) + .map(Backend::getDetailsForCreateReplica) + .collect(Collectors.toList())); + sb.append(", "); + } + return sb.toString(); + } + /** * Select a set of backends by the given policy. * diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java index 5f66e903e3a..50e9ac40bc7 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java @@ -294,7 +294,8 @@ public class CreateTableTest extends TestWithFeService { ExceptionChecker .expectThrowsWithMsg(DdlException.class, "Failed to find enough backend, please check the replication num,replication tag and storage medium and avail capacity of backends " - + "or maybe all be on same host.\n" + + "or maybe all be on same host." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation((short) 1)) + "\n" + "Create failed replications:\n" + "replication tag: {\"location\" : \"default\"}, replication num: 1, storage medium: SSD", () -> createTable( @@ -304,7 +305,8 @@ public class CreateTableTest extends TestWithFeService { ExceptionChecker .expectThrowsWithMsg(DdlException.class, "Failed to find enough backend, please check the replication num,replication tag and storage medium and avail capacity of backends " - + "or maybe all be on same host.\n" + + "or maybe all be on same host." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation((short) 1)) + "\n" + "Create failed replications:\n" + "replication tag: {\"location\" : \"default\"}, replication num: 1, storage medium: SSD", () -> createTable("create table test.tb7_1(key1 int, key2 varchar(10))\n" diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java index bce616b9cdc..9d9a4788b59 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java @@ -32,6 +32,7 @@ import org.apache.doris.system.Backend; import org.apache.doris.system.SystemInfoService; import org.apache.doris.utframe.UtFrameUtils; +import com.google.common.collect.Maps; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -85,7 +86,8 @@ public class ModifyBackendTest { CreateTableStmt createStmt = (CreateTableStmt) UtFrameUtils.parseAndAnalyzeStmt(createStr, connectContext); ExceptionChecker.expectThrowsWithMsg(DdlException.class, "Failed to find enough backend, please check the replication num,replication tag and storage medium and avail capacity of backends " - + "or maybe all be on same host.\n" + + "or maybe all be on same host." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation((short) 1)) + "\n" + "Create failed replications:\n" + "replication tag: {\"location\" : \"default\"}, replication num: 1, storage medium: HDD", () -> DdlExecutor.execute(Env.getCurrentEnv(), createStmt)); @@ -154,10 +156,13 @@ public class ModifyBackendTest { String partName = tbl.getPartitionNames().stream().findFirst().get(); String wrongAlterStr = "alter table test.tbl4 modify partition " + partName + " set ('replication_allocation' = 'tag.location.zonex:1')"; + Map<Tag, Short> allocMap = Maps.newHashMap(); + allocMap.put(Tag.create(Tag.TYPE_LOCATION, "zonex"), (short) 1); ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "errCode = 2," + " detailMessage = Failed to find enough backend, " + "please check the replication num,replication tag and storage medium and avail capacity of backends " - + "or maybe all be on same host.\n" + + "or maybe all be on same host." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation(allocMap)) + "\n" + "Create failed replications:\n" + "replication tag: {\"location\" : \"zonex\"}, replication num: 1, storage medium: null", () -> UtFrameUtils.parseAndAnalyzeStmt(wrongAlterStr, connectContext)); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/CreateTableCommandTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/CreateTableCommandTest.java index 741faea4a13..c64354fa96d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/CreateTableCommandTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/CreateTableCommandTest.java @@ -27,6 +27,7 @@ import org.apache.doris.catalog.Column; import org.apache.doris.catalog.Database; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.OlapTable; +import org.apache.doris.catalog.ReplicaAllocation; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.TabletMeta; import org.apache.doris.catalog.Type; @@ -285,7 +286,9 @@ public class CreateTableCommandTest extends TestWithFeService { ConfigBase.setMutableConfig("disable_storage_medium_check", "false"); checkThrow(org.apache.doris.common.DdlException.class, - "Failed to find enough backend, please check the replication num,replication tag and storage medium.\n" + "Failed to find enough backend, please check the replication num,replication tag and storage medium and avail capacity of backends " + + "or maybe all be on same host." + + Env.getCurrentSystemInfo().getDetailsForCreateReplica(new ReplicaAllocation((short) 1)) + "\n" + "Create failed replications:\n" + "replication tag: {\"location\" : \"default\"}, replication num: 1, storage medium: SSD", () -> createTable("create table test.tb7(key1 int, key2 varchar(10)) distributed by hash(key1) \n" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org