diff --git a/docs/en/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md b/docs/en/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md index c30ec0052394f..14f7dbbaa6d69 100644 --- a/docs/en/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md +++ b/docs/en/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md @@ -58,9 +58,9 @@ SHOW TABLET ### Query information of tablets in a table or a partition ```plain -+----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+ -| TabletId | ReplicaId | BackendId | SchemaHash | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | DataSize | RowCount | State | LstConsistencyCheckTime | CheckVersion | CheckVersionHash | VersionCount | PathHash | MetaUrl | CompactionStatus | -+----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+ ++----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+---------------+ +| TabletId | ReplicaId | BackendId | SchemaHash | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | DataSize | RowCount | State | LstConsistencyCheckTime | CheckVersion | CheckVersionHash | VersionCount | PathHash | MetaUrl | CompactionStatus | DiskRootPath | ++----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+---------------+ ``` | **Field** | **Description** | @@ -86,6 +86,7 @@ SHOW TABLET | PathHash | The hash of the directory in which the tablet is stored. | | MetaUrl | The URL used to query more meta information. | | CompactionStatus | The URL used to query data version compaction status. | +| DiskRootPath | The disk where the replica is located. | ### Query information of a specific tablet @@ -169,6 +170,7 @@ DISTRIBUTED BY HASH(`k1`, `k2`, `k3`); PathHash: 0 MetaUrl: http://172.26.92.141:8038/api/meta/header/9588955 CompactionStatus: http://172.26.92.141:8038/api/compaction/show?tablet_id=9588955 + DiskRootPath: /storage/disk ``` - Example 2: Query information of tablet 9588955. diff --git a/docs/zh/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md b/docs/zh/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md index 77ef496e1ccb5..c834cab518293 100644 --- a/docs/zh/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md +++ b/docs/zh/sql-reference/sql-statements/table_bucket_part_index/SHOW_TABLET.md @@ -61,9 +61,9 @@ SHOW TABLET ### 查看某张表或分区内的所有 tablet ```plain -+----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+ -| TabletId | ReplicaId | BackendId | SchemaHash | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | DataSize | RowCount | State | LstConsistencyCheckTime | CheckVersion | CheckVersionHash | VersionCount | PathHash | MetaUrl | CompactionStatus | -+----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+ ++----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+---------------+ +| TabletId | ReplicaId | BackendId | SchemaHash | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | DataSize | RowCount | State | LstConsistencyCheckTime | CheckVersion | CheckVersionHash | VersionCount | PathHash | MetaUrl | CompactionStatus | DiskRootPath | ++----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+------------------+--------------+----------+----------+-------------------+---------------+ ``` | **字段** | **说明** | @@ -89,6 +89,7 @@ SHOW TABLET | PathHash | Tablet 存储目录的 hash。 | | MetaUrl | 通过 URL 查询更多的 meta 信息。 | | CompactionStatus | 通过 URL 查询 Compaction 状态。 | +| DiskRootPath | 副本所在的磁盘。 | ### 查看单个 tablet @@ -172,6 +173,7 @@ DISTRIBUTED BY HASH(`k1`, `k2`, `k3`); PathHash: 0 MetaUrl: http://172.26.92.141:8038/api/meta/header/9588955 CompactionStatus: http://172.26.92.141:8038/api/compaction/show?tablet_id=9588955 + DiskRootPath: /storage/disk ``` - 查看 id 为 9588955 的 Tablet 的信息。 diff --git a/fe/fe-core/src/main/java/com/starrocks/common/proc/LocalTabletsProcDir.java b/fe/fe-core/src/main/java/com/starrocks/common/proc/LocalTabletsProcDir.java index 2f8bb9b647059..2de4fa19a45a9 100644 --- a/fe/fe-core/src/main/java/com/starrocks/common/proc/LocalTabletsProcDir.java +++ b/fe/fe-core/src/main/java/com/starrocks/common/proc/LocalTabletsProcDir.java @@ -72,6 +72,7 @@ public class LocalTabletsProcDir implements ProcDirInterface { .add("DataSize").add("RowCount").add("State") .add("LstConsistencyCheckTime").add("CheckVersion").add("CheckVersionHash") .add("VersionCount").add("PathHash").add("MetaUrl").add("CompactionStatus") + .add("DiskRootPath") .build(); private final Database db; @@ -144,18 +145,22 @@ public List> fetchComparableResult(long version, long backendId Backend backend = backendMap.get(replica.getBackendId()); String metaUrl; String compactionUrl; + String diskRootPath; if (backend != null) { String hostPort = hideIpPort ? "*:0" : NetUtils.getHostPortInAccessibleFormat(backend.getHost(), backend.getHttpPort()); metaUrl = String.format("http://" + hostPort + "/api/meta/header/%d", tabletId); compactionUrl = String.format( "http://" + hostPort + "/api/compaction/show?tablet_id=%d", tabletId); + diskRootPath = backend.getDiskRootPath(replica.getPathHash()); } else { metaUrl = "N/A"; compactionUrl = "N/A"; + diskRootPath = "N/A"; } tabletInfo.add(metaUrl); tabletInfo.add(compactionUrl); + tabletInfo.add(diskRootPath); tabletInfos.add(tabletInfo); } diff --git a/fe/fe-core/src/main/java/com/starrocks/system/Backend.java b/fe/fe-core/src/main/java/com/starrocks/system/Backend.java index c0b78a9819504..5e3a4ce7f85eb 100644 --- a/fe/fe-core/src/main/java/com/starrocks/system/Backend.java +++ b/fe/fe-core/src/main/java/com/starrocks/system/Backend.java @@ -373,6 +373,17 @@ public void cancelDisableDisk(String rootPath) throws DdlException { } } + public String getDiskRootPath(long pathHash) { + String rootPath = "Unknown"; + for (DiskInfo diskInfo : disksRef.values()) { + if (diskInfo.getPathHash() == pathHash) { + rootPath = diskInfo.getRootPath(); + break; + } + } + return rootPath; + } + public void setStorageMediumForAllDisks(TStorageMedium m) { for (DiskInfo diskInfo : disksRef.values()) { diskInfo.setStorageMedium(m); diff --git a/fe/fe-core/src/test/java/com/starrocks/common/proc/LocalTabletsProcDirTest.java b/fe/fe-core/src/test/java/com/starrocks/common/proc/LocalTabletsProcDirTest.java index b3ed511ab2db3..b5197b568e828 100644 --- a/fe/fe-core/src/test/java/com/starrocks/common/proc/LocalTabletsProcDirTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/common/proc/LocalTabletsProcDirTest.java @@ -22,6 +22,7 @@ import com.starrocks.catalog.Column; import com.starrocks.catalog.DataProperty; import com.starrocks.catalog.Database; +import com.starrocks.catalog.DiskInfo; import com.starrocks.catalog.DistributionInfo; import com.starrocks.catalog.HashDistributionInfo; import com.starrocks.catalog.KeysType; @@ -57,8 +58,24 @@ public void testFetchResultWithLocalTablet(@Mocked GlobalStateMgr globalStateMgr @Mocked SystemInfoService systemInfoService) { Map idToBackend = Maps.newHashMap(); long backendId = 20L; - idToBackend.put(backendId, new Backend(backendId, "127.0.0.1", 9050)); - idToBackend.put(backendId, new Backend(backendId + 1, "127.0.0.2", 9050)); + Backend b1 = new Backend(backendId, "127.0.0.1", 9050); + Map disks1 = Maps.newHashMap(); + DiskInfo d1 = new DiskInfo("/home/disk1"); + d1.setPathHash(1L); + disks1.put("/home/disk1", d1); + ImmutableMap immutableMap1 = ImmutableMap.copyOf(disks1); + b1.setDisks(immutableMap1); + + Backend b2 = new Backend(backendId + 1, "127.0.0.2", 9050); + Map disks2 = Maps.newHashMap(); + DiskInfo d2 = new DiskInfo("/home/disk2"); + d2.setPathHash(2L); + disks2.put("/home/disk2", d2); + ImmutableMap immutableMap2 = ImmutableMap.copyOf(disks2); + b2.setDisks(immutableMap2); + + idToBackend.put(backendId, b1); + idToBackend.put(backendId + 1, b2); new Expectations() { { @@ -87,6 +104,8 @@ public void testFetchResultWithLocalTablet(@Mocked GlobalStateMgr globalStateMgr // Replica Replica replica1 = new Replica(replicaId, backendId, Replica.ReplicaState.NORMAL, 1, 0); Replica replica2 = new Replica(replicaId + 1, backendId + 1, Replica.ReplicaState.NORMAL, 1, 0); + replica1.setPathHash(1L); + replica2.setPathHash(2L); // Tablet LocalTablet tablet1 = new LocalTablet(tablet1Id); @@ -127,12 +146,14 @@ public void testFetchResultWithLocalTablet(@Mocked GlobalStateMgr globalStateMgr System.out.println(result); Assert.assertEquals(3, result.size()); Assert.assertEquals((long) result.get(0).get(0), tablet1Id); + Assert.assertEquals(result.get(0).get(21), "/home/disk1"); Assert.assertEquals((long) result.get(1).get(0), tablet1Id); if ((long) result.get(0).get(1) == replicaId) { Assert.assertEquals((long) result.get(0).get(2), backendId); } else if ((long) result.get(0).get(1) == replicaId + 1) { Assert.assertEquals((long) result.get(0).get(2), backendId + 1); } + Assert.assertEquals(result.get(1).get(21), "/home/disk2"); Assert.assertEquals((long) result.get(2).get(0), tablet2Id); Assert.assertEquals(result.get(2).get(1), -1); Assert.assertEquals(result.get(2).get(2), -1);