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 04af57c5be [Improvement-17646][JdbcRegistry] Using transaction in 
JdbcRegistryDataManager (#17754)
04af57c5be is described below

commit 04af57c5bea08b83aa116e3ca93b01e0e6498a6a
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sat Dec 20 20:29:46 2025 +0800

    [Improvement-17646][JdbcRegistry] Using transaction in 
JdbcRegistryDataManager (#17754)
---
 .../en/guide/installation/registry-plugins/jdbc.md |  14 +--
 .../zh/guide/installation/registry-plugins/jdbc.md |  12 +--
 .../jdbc/JdbcRegistryAutoConfiguration.java        |  57 ++++++-----
 .../registry/jdbc/JdbcRegistryProperties.java      |   5 +-
 .../jdbc/server/JdbcRegistryDataManager.java       | 112 ++++++++++++---------
 .../jdbc/server/JdbcRegistryLockManager.java       |   4 +-
 .../registry/jdbc/server/JdbcRegistryServer.java   |   8 +-
 7 files changed, 106 insertions(+), 106 deletions(-)

diff --git a/docs/docs/en/guide/installation/registry-plugins/jdbc.md 
b/docs/docs/en/guide/installation/registry-plugins/jdbc.md
index 548459663e..33c8aaa393 100644
--- a/docs/docs/en/guide/installation/registry-plugins/jdbc.md
+++ b/docs/docs/en/guide/installation/registry-plugins/jdbc.md
@@ -38,19 +38,13 @@ registry:
   heartbeat-refresh-interval: 3s
   # Once the client's heartbeat is not refresh in this time, the server will 
consider the client is offline.
   session-timeout: 60s
-  # The hikari configuration, default will use the same datasource pool as 
DolphinScheduler.
-  hikari-config:
-    jdbc-url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler
-    username: root
-    password: root
-    maximum-pool-size: 5
-    connection-timeout: 9000
-    idle-timeout: 600000
 ```
 
-## Use different database configuration for jdbc registry center
+## Set DataSource for worker
 
-You need to set the registry properties in master/worker/api's application.yml
+Since worker server doesn't contain datasource, so you need to config 
datasource for worker.
+
+You need to set the registry hikari-config properties at worker's 
application.yml
 
 ### Use Mysql as registry center
 
diff --git a/docs/docs/zh/guide/installation/registry-plugins/jdbc.md 
b/docs/docs/zh/guide/installation/registry-plugins/jdbc.md
index 1a77b4e537..de1b6fdeb3 100644
--- a/docs/docs/zh/guide/installation/registry-plugins/jdbc.md
+++ b/docs/docs/zh/guide/installation/registry-plugins/jdbc.md
@@ -32,19 +32,11 @@ registry:
   heartbeat-refresh-interval: 3s
   # Once the client's heartbeat is not refresh in this time, the server will 
consider the client is offline.
   session-timeout: 60s
-  # The hikari configuration, default will use the same datasource pool as 
DolphinScheduler.
-  hikari-config:
-    jdbc-url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler
-    username: root
-    password: root
-    maximum-pool-size: 5
-    connection-timeout: 9000
-    idle-timeout: 600000
 ```
 
-## 对 JDBC 注册中心使用不同的数据库配置
+## 为 worker 配置数据源
 
-需要在 master/worker/api 的 application.yml 中设置属性
+由于Worker服务默认不包含数据源,因此你需要在 worker 的 application.yml 中为注册中心设置数据源属性
 
 ### 使用 MySQL 作为注册中心
 
diff --git 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryAutoConfiguration.java
 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryAutoConfiguration.java
index d7bb5cd879..c598cd53f6 100644
--- 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryAutoConfiguration.java
+++ 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryAutoConfiguration.java
@@ -17,10 +17,6 @@
 
 package org.apache.dolphinscheduler.plugin.registry.jdbc;
 
-import 
org.apache.dolphinscheduler.plugin.registry.jdbc.mapper.JdbcRegistryClientHeartbeatMapper;
-import 
org.apache.dolphinscheduler.plugin.registry.jdbc.mapper.JdbcRegistryDataChangeEventMapper;
-import 
org.apache.dolphinscheduler.plugin.registry.jdbc.mapper.JdbcRegistryDataMapper;
-import 
org.apache.dolphinscheduler.plugin.registry.jdbc.mapper.JdbcRegistryLockMapper;
 import 
org.apache.dolphinscheduler.plugin.registry.jdbc.repository.JdbcRegistryClientRepository;
 import 
org.apache.dolphinscheduler.plugin.registry.jdbc.repository.JdbcRegistryDataChangeEventRepository;
 import 
org.apache.dolphinscheduler.plugin.registry.jdbc.repository.JdbcRegistryDataRepository;
@@ -30,6 +26,8 @@ import 
org.apache.dolphinscheduler.plugin.registry.jdbc.server.JdbcRegistryServe
 
 import org.apache.ibatis.session.SqlSessionFactory;
 
+import javax.sql.DataSource;
+
 import lombok.extern.slf4j.Slf4j;
 
 import org.mybatis.spring.SqlSessionTemplate;
@@ -40,6 +38,9 @@ import 
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
 
 import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
 import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
@@ -62,13 +63,15 @@ public class JdbcRegistryAutoConfiguration {
                                                   JdbcRegistryLockRepository 
jdbcRegistryLockRepository,
                                                   JdbcRegistryClientRepository 
jdbcRegistryClientRepository,
                                                   
JdbcRegistryDataChangeEventRepository jdbcRegistryDataChangeEventRepository,
-                                                  JdbcRegistryProperties 
jdbcRegistryProperties) {
+                                                  JdbcRegistryProperties 
jdbcRegistryProperties,
+                                                  TransactionTemplate 
jdbcTransactionTemplate) {
         return new JdbcRegistryServer(
                 jdbcRegistryDataRepository,
                 jdbcRegistryLockRepository,
                 jdbcRegistryClientRepository,
                 jdbcRegistryDataChangeEventRepository,
-                jdbcRegistryProperties);
+                jdbcRegistryProperties,
+                jdbcTransactionTemplate);
     }
 
     @Bean
@@ -81,42 +84,38 @@ public class JdbcRegistryAutoConfiguration {
 
     @Bean
     @ConditionalOnMissingBean
-    public SqlSessionFactory sqlSessionFactory(JdbcRegistryProperties 
jdbcRegistryProperties) throws Exception {
-        log.info("Initialize jdbcRegistrySqlSessionFactory");
-        MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new 
MybatisSqlSessionFactoryBean();
-        sqlSessionFactoryBean.setDataSource(new 
HikariDataSource(jdbcRegistryProperties.getHikariConfig()));
-        return sqlSessionFactoryBean.getObject();
+    public DataSource jdbcRegistryDataSource(JdbcRegistryProperties 
jdbcRegistryProperties) {
+        return new HikariDataSource(jdbcRegistryProperties.getHikariConfig());
     }
 
     @Bean
     @ConditionalOnMissingBean
-    public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory 
jdbcRegistrySqlSessionFactory) {
-        log.info("Initialize jdbcRegistrySqlSessionTemplate");
-        return new SqlSessionTemplate(jdbcRegistrySqlSessionFactory);
-    }
-
-    @Bean
-    public JdbcRegistryDataMapper jdbcRegistryDataMapper(SqlSessionTemplate 
jdbcRegistrySqlSessionTemplate) {
-        
jdbcRegistrySqlSessionTemplate.getConfiguration().addMapper(JdbcRegistryDataMapper.class);
-        return 
jdbcRegistrySqlSessionTemplate.getMapper(JdbcRegistryDataMapper.class);
+    public PlatformTransactionManager 
jdbcRegistryTransactionManager(DataSource jdbcRegistryDataSource) {
+        DataSourceTransactionManager transactionManager = new 
DataSourceTransactionManager();
+        transactionManager.setDataSource(jdbcRegistryDataSource);
+        return transactionManager;
     }
 
     @Bean
-    public JdbcRegistryLockMapper jdbcRegistryLockMapper(SqlSessionTemplate 
jdbcRegistrySqlSessionTemplate) {
-        
jdbcRegistrySqlSessionTemplate.getConfiguration().addMapper(JdbcRegistryLockMapper.class);
-        return 
jdbcRegistrySqlSessionTemplate.getMapper(JdbcRegistryLockMapper.class);
+    @ConditionalOnMissingBean
+    public TransactionTemplate 
jdbcTransactionTemplate(PlatformTransactionManager 
jdbcRegistryTransactionManager) {
+        TransactionTemplate transactionTemplate = new TransactionTemplate();
+        
transactionTemplate.setTransactionManager(jdbcRegistryTransactionManager);
+        return transactionTemplate;
     }
 
     @Bean
-    public JdbcRegistryDataChangeEventMapper 
jdbcRegistryDataChangeEventMapper(SqlSessionTemplate 
jdbcRegistrySqlSessionTemplate) {
-        
jdbcRegistrySqlSessionTemplate.getConfiguration().addMapper(JdbcRegistryDataChangeEventMapper.class);
-        return 
jdbcRegistrySqlSessionTemplate.getMapper(JdbcRegistryDataChangeEventMapper.class);
+    @ConditionalOnMissingBean
+    public SqlSessionFactory jdbcRegistrySqlSessionFactory(DataSource 
jdbcRegistryDataSource) throws Exception {
+        MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new 
MybatisSqlSessionFactoryBean();
+        sqlSessionFactoryBean.setDataSource(jdbcRegistryDataSource);
+        return sqlSessionFactoryBean.getObject();
     }
 
     @Bean
-    public JdbcRegistryClientHeartbeatMapper 
jdbcRegistryClientHeartbeatMapper(SqlSessionTemplate 
jdbcRegistrySqlSessionTemplate) {
-        
jdbcRegistrySqlSessionTemplate.getConfiguration().addMapper(JdbcRegistryClientHeartbeatMapper.class);
-        return 
jdbcRegistrySqlSessionTemplate.getMapper(JdbcRegistryClientHeartbeatMapper.class);
+    @ConditionalOnMissingBean
+    public SqlSessionTemplate jdbcRegistrySqlSessionTemplate(SqlSessionFactory 
jdbcRegistrySqlSessionFactory) {
+        return new SqlSessionTemplate(jdbcRegistrySqlSessionFactory);
     }
 
 }
diff --git 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryProperties.java
 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryProperties.java
index de98ec3184..21f6744a66 100644
--- 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryProperties.java
+++ 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryProperties.java
@@ -65,13 +65,13 @@ public class JdbcRegistryProperties implements Validator {
         JdbcRegistryProperties jdbcRegistryProperties = 
(JdbcRegistryProperties) target;
         if 
(jdbcRegistryProperties.getHeartbeatRefreshInterval().compareTo(MIN_HEARTBEAT_REFRESH_INTERVAL)
 < 0) {
             errors.rejectValue("heartbeatRefreshInterval", 
"heartbeatRefreshInterval",
-                    "heartbeatRefreshInterval must be greater than 1s");
+                    "registry.heartbeatRefreshInterval must be greater than 
1s");
         }
 
         if (jdbcRegistryProperties.getSessionTimeout().toMillis() < 3
                 * 
jdbcRegistryProperties.getHeartbeatRefreshInterval().toMillis()) {
             errors.rejectValue("sessionTimeout", "sessionTimeout",
-                    "sessionTimeout must be greater than 3 * 
heartbeatRefreshInterval");
+                    "registry.sessionTimeout must be greater than 3 * 
heartbeatRefreshInterval");
         }
         if (StringUtils.isEmpty(jdbcRegistryClientName)) {
             jdbcRegistryClientName = NetUtils.getHost() + ":" + serverPort;
@@ -86,7 +86,6 @@ public class JdbcRegistryProperties implements Validator {
                         "\n  jdbcRegistryClientName -> " + 
jdbcRegistryClientName +
                         "\n  heartbeatRefreshInterval -> " + 
heartbeatRefreshInterval +
                         "\n  sessionTimeout -> " + sessionTimeout +
-                        "\n  hikariConfig -> " + hikariConfig +
                         
"\n****************************JdbcRegistryProperties**************************************";
         log.info(config);
     }
diff --git 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryDataManager.java
 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryDataManager.java
index 595d6f4ebb..08eb053176 100644
--- 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryDataManager.java
+++ 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryDataManager.java
@@ -41,6 +41,8 @@ import java.util.stream.Collectors;
 
 import lombok.extern.slf4j.Slf4j;
 
+import org.springframework.transaction.support.TransactionTemplate;
+
 import com.google.common.collect.Lists;
 
 @Slf4j
@@ -57,23 +59,27 @@ public class JdbcRegistryDataManager
 
     private final JdbcRegistryDataChangeEventRepository 
jdbcRegistryDataChangeEventRepository;
 
+    private final TransactionTemplate jdbcRegistryTransactionTemplate;
+
     private final List<RegistryRowChangeListener<JdbcRegistryDataDTO>> 
registryRowChangeListeners;
 
     private long lastDetectedJdbcRegistryDataChangeEventId = -1;
 
     public JdbcRegistryDataManager(JdbcRegistryProperties registryProperties,
                                    JdbcRegistryDataRepository 
jdbcRegistryDataRepository,
-                                   JdbcRegistryDataChangeEventRepository 
jdbcRegistryDataChangeEventRepository) {
+                                   JdbcRegistryDataChangeEventRepository 
jdbcRegistryDataChangeEventRepository,
+                                   TransactionTemplate 
jdbcRegistryTransactionTemplate) {
         this.registryProperties = registryProperties;
         this.jdbcRegistryDataChangeEventRepository = 
jdbcRegistryDataChangeEventRepository;
         this.jdbcRegistryDataRepository = jdbcRegistryDataRepository;
+        this.jdbcRegistryTransactionTemplate = jdbcRegistryTransactionTemplate;
         this.registryRowChangeListeners = new CopyOnWriteArrayList<>();
-        this.lastDetectedJdbcRegistryDataChangeEventId =
-                
jdbcRegistryDataChangeEventRepository.getMaxJdbcRegistryDataChangeEventId();
     }
 
     @Override
     public void start() {
+        this.lastDetectedJdbcRegistryDataChangeEventId =
+                
jdbcRegistryDataChangeEventRepository.getMaxJdbcRegistryDataChangeEventId();
         
JdbcRegistryThreadFactory.getDefaultSchedulerThreadExecutor().scheduleWithFixedDelay(
                 this::detectJdbcRegistryDataChangeEvent,
                 registryProperties.getHeartbeatRefreshInterval().toMillis(),
@@ -162,67 +168,73 @@ public class JdbcRegistryDataManager
         checkNotNull(key);
         checkNotNull(dataType);
 
-        Optional<JdbcRegistryDataDTO> jdbcRegistryDataOptional = 
jdbcRegistryDataRepository.selectByKey(key);
-        if (jdbcRegistryDataOptional.isPresent()) {
-            JdbcRegistryDataDTO jdbcRegistryData = 
jdbcRegistryDataOptional.get();
-            if (!dataType.name().equals(jdbcRegistryData.getDataType())) {
-                throw new UnsupportedOperationException("The data type: " + 
jdbcRegistryData.getDataType()
-                        + " of the key: " + key + " cannot be updated");
-            }
+        final Optional<JdbcRegistryDataDTO> jdbcRegistryDataOptional = 
jdbcRegistryDataRepository.selectByKey(key);
 
-            if 
(DataType.EPHEMERAL.name().equals(jdbcRegistryData.getDataType())) {
-                if (!jdbcRegistryData.getClientId().equals(clientId)) {
-                    throw new UnsupportedOperationException(
-                            "The EPHEMERAL data: " + key + " can only be 
updated by its owner: "
-                                    + jdbcRegistryData.getClientId() + " but 
not: " + clientId);
+        jdbcRegistryTransactionTemplate.execute(status -> {
+            if (jdbcRegistryDataOptional.isPresent()) {
+                JdbcRegistryDataDTO jdbcRegistryData = 
jdbcRegistryDataOptional.get();
+                if (!dataType.name().equals(jdbcRegistryData.getDataType())) {
+                    throw new UnsupportedOperationException("The data type: " 
+ jdbcRegistryData.getDataType()
+                            + " of the key: " + key + " cannot be updated");
                 }
-            }
 
-            jdbcRegistryData.setDataValue(value);
-            jdbcRegistryData.setLastUpdateTime(new Date());
-            jdbcRegistryDataRepository.updateById(jdbcRegistryData);
+                if 
(DataType.EPHEMERAL.name().equals(jdbcRegistryData.getDataType())) {
+                    if (!jdbcRegistryData.getClientId().equals(clientId)) {
+                        throw new UnsupportedOperationException(
+                                "The EPHEMERAL data: " + key + " can only be 
updated by its owner: "
+                                        + jdbcRegistryData.getClientId() + " 
but not: " + clientId);
+                    }
+                }
 
-            JdbcRegistryDataChangeEventDTO jdbcRegistryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
-                    .jdbcRegistryData(jdbcRegistryData)
-                    .eventType(JdbcRegistryDataChangeEventDTO.EventType.UPDATE)
-                    .createTime(new Date())
-                    .build();
-            
jdbcRegistryDataChangeEventRepository.insert(jdbcRegistryDataChangeEvent);
-        } else {
-            JdbcRegistryDataDTO jdbcRegistryDataDTO = 
JdbcRegistryDataDTO.builder()
-                    .clientId(clientId)
-                    .dataKey(key)
-                    .dataValue(value)
-                    .dataType(dataType.name())
-                    .createTime(new Date())
-                    .lastUpdateTime(new Date())
-                    .build();
-            jdbcRegistryDataRepository.insert(jdbcRegistryDataDTO);
-            JdbcRegistryDataChangeEventDTO registryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
-                    .jdbcRegistryData(jdbcRegistryDataDTO)
-                    .eventType(JdbcRegistryDataChangeEventDTO.EventType.ADD)
-                    .createTime(new Date())
-                    .build();
-            
jdbcRegistryDataChangeEventRepository.insert(registryDataChangeEvent);
-        }
+                jdbcRegistryData.setDataValue(value);
+                jdbcRegistryData.setLastUpdateTime(new Date());
+                jdbcRegistryDataRepository.updateById(jdbcRegistryData);
+
+                JdbcRegistryDataChangeEventDTO jdbcRegistryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
+                        .jdbcRegistryData(jdbcRegistryData)
+                        
.eventType(JdbcRegistryDataChangeEventDTO.EventType.UPDATE)
+                        .createTime(new Date())
+                        .build();
+                
jdbcRegistryDataChangeEventRepository.insert(jdbcRegistryDataChangeEvent);
+            } else {
+                JdbcRegistryDataDTO jdbcRegistryDataDTO = 
JdbcRegistryDataDTO.builder()
+                        .clientId(clientId)
+                        .dataKey(key)
+                        .dataValue(value)
+                        .dataType(dataType.name())
+                        .createTime(new Date())
+                        .lastUpdateTime(new Date())
+                        .build();
+                jdbcRegistryDataRepository.insert(jdbcRegistryDataDTO);
+                JdbcRegistryDataChangeEventDTO registryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
+                        .jdbcRegistryData(jdbcRegistryDataDTO)
+                        
.eventType(JdbcRegistryDataChangeEventDTO.EventType.ADD)
+                        .createTime(new Date())
+                        .build();
+                
jdbcRegistryDataChangeEventRepository.insert(registryDataChangeEvent);
+            }
+            return null;
+        });
 
     }
 
     @Override
     public void deleteJdbcRegistryDataByKey(String key) {
         checkNotNull(key);
-        // todo: this is not atomic, need to be improved
         Optional<JdbcRegistryDataDTO> jdbcRegistryDataOptional = 
jdbcRegistryDataRepository.selectByKey(key);
         if (!jdbcRegistryDataOptional.isPresent()) {
             return;
         }
-        jdbcRegistryDataRepository.deleteByKey(key);
-        final JdbcRegistryDataChangeEventDTO registryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
-                .jdbcRegistryData(jdbcRegistryDataOptional.get())
-                .eventType(JdbcRegistryDataChangeEventDTO.EventType.DELETE)
-                .createTime(new Date())
-                .build();
-        jdbcRegistryDataChangeEventRepository.insert(registryDataChangeEvent);
+        jdbcRegistryTransactionTemplate.execute(status -> {
+            jdbcRegistryDataRepository.deleteByKey(key);
+            final JdbcRegistryDataChangeEventDTO registryDataChangeEvent = 
JdbcRegistryDataChangeEventDTO.builder()
+                    .jdbcRegistryData(jdbcRegistryDataOptional.get())
+                    .eventType(JdbcRegistryDataChangeEventDTO.EventType.DELETE)
+                    .createTime(new Date())
+                    .build();
+            
jdbcRegistryDataChangeEventRepository.insert(registryDataChangeEvent);
+            return null;
+        });
     }
 
     private void 
doTriggerJdbcRegistryDataAddedListener(List<JdbcRegistryDataDTO> valuesToAdd) {
diff --git 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryLockManager.java
 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryLockManager.java
index 434f5c49b7..68ba187778 100644
--- 
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryLockManager.java
+++ 
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/server/JdbcRegistryLockManager.java
@@ -79,7 +79,7 @@ public class JdbcRegistryLockManager implements 
IJdbcRegistryLockManager {
                 // The lock is already exist, wait it release.
                 continue;
             }
-            log.debug("Acquire the lock {} failed try again", lockKey);
+            log.debug("{} acquire the lock {} failed try again", lockOwner, 
lockKey);
             // acquire failed, wait and try again
             
ThreadUtils.sleep(jdbcRegistryProperties.getHeartbeatRefreshInterval().toMillis());
         }
@@ -123,7 +123,7 @@ public class JdbcRegistryLockManager implements 
IJdbcRegistryLockManager {
                 // The lock is already exist, wait it release.
                 continue;
             }
-            log.debug("Acquire the lock {} failed try again", lockKey);
+            log.debug("{} acquire the lock {} failed try again", lockOwner, 
lockKey);
             // acquire failed, wait and try again
             
ThreadUtils.sleep(jdbcRegistryProperties.getHeartbeatRefreshInterval().toMillis());
         }
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 feaaf5a9bd..a7b75424ea 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
@@ -49,6 +49,8 @@ import java.util.stream.Collectors;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 
+import org.springframework.transaction.support.TransactionTemplate;
+
 import com.google.common.collect.Lists;
 
 /**
@@ -84,13 +86,15 @@ public class JdbcRegistryServer implements 
IJdbcRegistryServer {
                               JdbcRegistryLockRepository 
jdbcRegistryLockRepository,
                               JdbcRegistryClientRepository 
jdbcRegistryClientRepository,
                               JdbcRegistryDataChangeEventRepository 
jdbcRegistryDataChangeEventRepository,
-                              JdbcRegistryProperties jdbcRegistryProperties) {
+                              JdbcRegistryProperties jdbcRegistryProperties,
+                              TransactionTemplate transactionTemplate) {
         this.jdbcRegistryDataRepository = 
checkNotNull(jdbcRegistryDataRepository);
         this.jdbcRegistryLockRepository = 
checkNotNull(jdbcRegistryLockRepository);
         this.jdbcRegistryClientRepository = 
checkNotNull(jdbcRegistryClientRepository);
         this.jdbcRegistryProperties = checkNotNull(jdbcRegistryProperties);
         this.jdbcRegistryDataManager = new JdbcRegistryDataManager(
-                jdbcRegistryProperties, jdbcRegistryDataRepository, 
jdbcRegistryDataChangeEventRepository);
+                jdbcRegistryProperties, jdbcRegistryDataRepository, 
jdbcRegistryDataChangeEventRepository,
+                transactionTemplate);
         this.jdbcRegistryLockManager = new JdbcRegistryLockManager(
                 jdbcRegistryProperties, jdbcRegistryLockRepository);
         this.jdbcRegistryServerState = JdbcRegistryServerState.INIT;

Reply via email to