This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 60ff52169b0 [branch-2.0](create table) show failed detail msg(#41463)
(#41545)
60ff52169b0 is described below
commit 60ff52169b015537de00967b5444334cb30ab7c8
Author: yujun <[email protected]>
AuthorDate: Thu Oct 10 11:16:02 2024 +0800
[branch-2.0](create table) show failed detail msg(#41463) (#41545)
cherry-pick: #41463
---
.../doris/common/util/DynamicPartitionUtil.java | 3 +-
.../main/java/org/apache/doris/system/Backend.java | 65 ++++++++++++++++++++++
.../org/apache/doris/system/SystemInfoService.java | 16 +++++-
.../org/apache/doris/catalog/CreateTableTest.java | 9 ++-
.../apache/doris/catalog/ModifyBackendTest.java | 20 +++++--
5 files changed, 103 insertions(+), 10 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 bf00a181177..cae5ec3c643 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
@@ -253,7 +253,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 c41a70d60ae..ae93b7faab6 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
@@ -233,6 +233,71 @@ public class Backend implements Writable {
this.backendStatus.isLoadDisabled = isLoadDisabled;
}
+ 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 380a976cbef..6b4c2bee09f 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
@@ -526,7 +526,9 @@ public class SystemInfoService {
if (!failedEntries.isEmpty()) {
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.\n" + "Create
failed replications:\n" + failedMsg);
+ + "replication tag and storage medium and avail
capacity of backends "
+ + "or maybe all be on same host." +
getDetailsForCreateReplica(replicaAlloc) + "\n"
+ + "Create failed replications:\n" + failedMsg);
}
}
@@ -534,6 +536,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 4001d805f1a..15745a70071 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
@@ -305,7 +305,10 @@ public class CreateTableTest {
ConfigBase.setMutableConfig("disable_storage_medium_check", "false");
ExceptionChecker
- .expectThrowsWithMsg(DdlException.class, "Failed to find
enough backend, please check the replication num,replication tag and storage
medium.\n"
+ .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."
+ +
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"
@@ -313,7 +316,9 @@ public class CreateTableTest {
ExceptionChecker
.expectThrowsWithMsg(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_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 3bd00d2b73a..825bfff57a2 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
@@ -31,6 +31,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;
@@ -81,7 +82,10 @@ public class ModifyBackendTest {
String createStr = "create table test.tbl1(\n" + "k1 int\n" + ")
distributed by hash(k1)\n"
+ "buckets 3 properties(\n" + "\"replication_num\" = \"1\"\n"
+ ");";
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.\n"
+ 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."
+ +
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));
@@ -150,11 +154,15 @@ 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')";
- ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "errCode
= 2, detailMessage = "
- + "errCode = 2, detailMessage = Failed to find enough backend,
"
- + "please check the replication num,replication tag and
storage medium.\n"
- + "Create failed replications:\n"
- + "replication tag: {\"location\" : \"zonex\"}, replication
num: 1, storage medium: null",
+ 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."
+ +
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));
tblProperties = tableProperty.getProperties();
Assert.assertTrue(tblProperties.containsKey("default.replication_allocation"));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]