This is an automated email from the ASF dual-hosted git repository.
wangzhen pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.8 by this push:
new 5dca0e095 [KYUUBI #6048] Assign serviceNode and add volatile for
variables
5dca0e095 is described below
commit 5dca0e09554e9f887d362cad39ece9fabad76202
Author: wforget <[email protected]>
AuthorDate: Thu Feb 8 09:35:20 2024 +0800
[KYUUBI #6048] Assign serviceNode and add volatile for variables
# :mag: Description
## Issue References ๐
This pull request fixes #
## Describe Your Solution ๐ง
Fix the following issues:
+ `EtcdDiscoveryClient#serviceNode` has never been assigned.
+ Variables in EtcdDiscoveryClient may be accessed by multiple threads.
## Types of changes :bookmark:
- [X] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6048 from wForget/hotfix.
Closes #6048
79aa971d9 [wforget] Assign serviceNode and add volatile to the variables
Authored-by: wforget <[email protected]>
Signed-off-by: wforget <[email protected]>
(cherry picked from commit 19c0576a34223e8e33490aa47b6f1a77b538c997)
Signed-off-by: wforget <[email protected]>
---
.../apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git
a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala
b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala
index 7edc7e8a3..9ab4d9da7 100644
---
a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala
+++
b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala
@@ -58,13 +58,13 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends
DiscoveryClient {
case class ServiceNode(path: String, lease: Long)
- var client: Client = _
- var kvClient: KV = _
- var lockClient: Lock = _
- var leaseClient: Lease = _
- var serviceNode: ServiceNode = _
+ @volatile var client: Client = _
+ @volatile var kvClient: KV = _
+ @volatile var lockClient: Lock = _
+ @volatile var leaseClient: Lease = _
+ @volatile var serviceNode: ServiceNode = _
- var leaseTTL: Long = _
+ @volatile var leaseTTL: Long = _
private def buildClient(): Client = {
val endpoints = conf.get(HA_ADDRESSES).split(",")
@@ -250,7 +250,7 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends
DiscoveryClient {
val instance = serviceDiscovery.fe.connectionUrl
val watcher = new DeRegisterWatcher(instance, serviceDiscovery)
- val serviceNode = createPersistentNode(
+ serviceNode = createPersistentNode(
conf,
namespace,
instance,