This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 0b1f1f7418 [Fix-17643] [registry-jdbc] fix dead client haven't fired
JdbcDataChangeEvent issue (#17645)
0b1f1f7418 is described below
commit 0b1f1f7418bee758407f11b0a0f3d3c7b0c1c762
Author: qiong-zhou <[email protected]>
AuthorDate: Thu Nov 13 09:46:46 2025 +0800
[Fix-17643] [registry-jdbc] fix dead client haven't fired
JdbcDataChangeEvent issue (#17645)
---
.../registry/jdbc/repository/JdbcRegistryClientRepository.java | 3 ++-
.../plugin/registry/jdbc/server/JdbcRegistryServer.java | 10 +++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/repository/JdbcRegistryClientRepository.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/repository/JdbcRegistryClientRepository.java
index f9ae2c6ef1..1791f3c942 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/repository/JdbcRegistryClientRepository.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/repository/JdbcRegistryClientRepository.java
@@ -25,6 +25,7 @@ import
org.apache.dolphinscheduler.plugin.registry.jdbc.model.DTO.JdbcRegistryCl
import org.apache.commons.collections4.CollectionUtils;
+import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@@ -44,7 +45,7 @@ public class JdbcRegistryClientRepository {
.collect(Collectors.toList());
}
- public void deleteByIds(List<Long> clientIds) {
+ public void deleteByIds(Collection<Long> clientIds) {
if (CollectionUtils.isEmpty(clientIds)) {
return;
}
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryServer.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryServer.java
index 45faa2eaa2..feaaf5a9bd 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryServer.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryServer.java
@@ -35,6 +35,7 @@ import
org.apache.dolphinscheduler.registry.api.RegistryException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.time.StopWatch;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -265,17 +266,18 @@ public class JdbcRegistryServer implements
IJdbcRegistryServer {
}
// remove the client which is already dead from the registry, and
remove it's related data and lock.
final List<JdbcRegistryClientHeartbeatDTO> jdbcRegistryClients =
jdbcRegistryClientRepository.queryAll();
- final List<Long> deadJdbcRegistryClientIds = jdbcRegistryClients
+ final Set<Long> deadJdbcRegistryClientIds = jdbcRegistryClients
.stream()
.filter(JdbcRegistryClientHeartbeatDTO::isDead)
.map(JdbcRegistryClientHeartbeatDTO::getId)
- .collect(Collectors.toList());
+ .collect(Collectors.toSet());
doPurgeJdbcRegistryClientInDB(deadJdbcRegistryClientIds);
// remove the data and lock which client is not exist.
final Set<Long> existJdbcRegistryClientIds = jdbcRegistryClients
.stream()
.map(JdbcRegistryClientHeartbeatDTO::getId)
+ .filter(id -> !deadJdbcRegistryClientIds.contains(id))
.collect(Collectors.toSet());
jdbcRegistryDataManager.getAllJdbcRegistryData()
.stream()
@@ -298,13 +300,11 @@ public class JdbcRegistryServer implements
IJdbcRegistryServer {
log.debug("Success purge invalid jdbcRegistryMetadata, cost: {} ms",
stopWatch.getTime());
}
- private void doPurgeJdbcRegistryClientInDB(final List<Long>
jdbcRegistryClientIds) {
+ private void doPurgeJdbcRegistryClientInDB(final Collection<Long>
jdbcRegistryClientIds) {
if (CollectionUtils.isEmpty(jdbcRegistryClientIds)) {
return;
}
log.info("Begin to delete dead jdbcRegistryClient: {}",
jdbcRegistryClientIds);
-
jdbcRegistryDataRepository.deleteEphemeralDateByClientIds(jdbcRegistryClientIds);
- jdbcRegistryLockRepository.deleteByClientIds(jdbcRegistryClientIds);
jdbcRegistryClientRepository.deleteByIds(jdbcRegistryClientIds);
log.info("Success delete dead jdbcRegistryClient: {}",
jdbcRegistryClientIds);
}