This is an automated email from the ASF dual-hosted git repository.
yuqi4733 pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new dd3faaa42a [#6722] fix(jdbc-doris): use `show backends` to get the
count of Doris BE nodes (#6884) (#6904)
dd3faaa42a is described below
commit dd3faaa42a263395b0909cc4650122773b85de55
Author: Kang <[email protected]>
AuthorDate: Mon Apr 14 09:02:27 2025 +0800
[#6722] fix(jdbc-doris): use `show backends` to get the count of Doris BE
nodes (#6884) (#6904)
### What changes were proposed in this pull request?
use `show backends` to get the count of Doris Backend (BE) nodes
### Why are the changes needed?
Fix: #6722
### Does this PR introduce _any_ user-facing change?
N/A
### How was this patch tested?
IT
---
.../doris/operation/DorisTableOperations.java | 27 +++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git
a/catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java
b/catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java
index 829088f013..425bf51d4c 100644
---
a/catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java
+++
b/catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java
@@ -159,24 +159,29 @@ public class DorisTableOperations extends
JdbcTableOperations {
// If the backend server is less than
DEFAULT_REPLICATION_FACTOR_IN_SERVER_SIDE (3), we need to
// set the property 'replication_num' to 1 explicitly.
if (!resultMap.containsKey(REPLICATION_FACTOR)) {
- // Try to check the number of backend servers.
- String query = "select count(*) from information_schema.backends where
Alive = 'true'";
+ // Try to check the number of backend servers using `show backends`,
this SQL is supported by
+ // all versions of Doris
+ String query = "show backends";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query)) {
+ int backendCount = 0;
while (resultSet.next()) {
- int backendCount = resultSet.getInt(1);
- if (backendCount < DEFAULT_REPLICATION_FACTOR_IN_SERVER_SIDE) {
- resultMap.put(
- REPLICATION_FACTOR,
- DORIS_TABLE_PROPERTIES_META
- .propertyEntries()
- .get(REPLICATION_FACTOR)
- .getDefaultValue()
- .toString());
+ String alive = resultSet.getString("Alive");
+ if ("true".equalsIgnoreCase(alive)) {
+ backendCount++;
}
}
+ if (backendCount < DEFAULT_REPLICATION_FACTOR_IN_SERVER_SIDE) {
+ resultMap.put(
+ REPLICATION_FACTOR,
+ DORIS_TABLE_PROPERTIES_META
+ .propertyEntries()
+ .get(REPLICATION_FACTOR)
+ .getDefaultValue()
+ .toString());
+ }
} catch (Exception e) {
throw new RuntimeException("Failed to get the number of backend
servers", e);
}