This is an automated email from the ASF dual-hosted git repository.

zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a20d3ff64ce Delay is Long.MAX_VALUE if show slave status result is 
null or second_behind_master is null (#18362)
a20d3ff64ce is described below

commit a20d3ff64ce6adf56dd03586f9f0b29b5967afdd
Author: natehuang <[email protected]>
AuthorDate: Thu Jun 16 17:12:42 2022 +0800

    Delay is Long.MAX_VALUE if show slave status result is null or 
second_behind_master is null (#18362)
---
 .../MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProvi
 [...]
index ce0d0c32ed3..f9aaa998ede 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
@@ -124,7 +124,11 @@ public final class 
MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm impl
     
     private long queryReplicationDelayMilliseconds(final Statement statement) 
throws SQLException {
         try (ResultSet resultSet = statement.executeQuery(SHOW_SLAVE_STATUS)) {
-            return resultSet.next() ? 
resultSet.getLong("Seconds_Behind_Master") * 1000L : 0L;
+            if (resultSet.next()) {
+                long delay = resultSet.getLong("Seconds_Behind_Master") * 1000;
+                return resultSet.wasNull() ? Long.MAX_VALUE : delay;
+            }
+            return Long.MAX_VALUE;
         }
     }
     

Reply via email to