Skip to content

Commit 5dca0e0

Browse files
committed
[KYUUBI #6048] Assign serviceNode and add volatile for variables
# 🔍 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 🔖 - [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 ⚰️ #### Behavior With This Pull Request 🎉 #### 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 79aa971 [wforget] Assign serviceNode and add volatile to the variables Authored-by: wforget <643348094@qq.com> Signed-off-by: wforget <643348094@qq.com> (cherry picked from commit 19c0576) Signed-off-by: wforget <643348094@qq.com>
1 parent e43ddb8 commit 5dca0e0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends DiscoveryClient {
5858

5959
case class ServiceNode(path: String, lease: Long)
6060

61-
var client: Client = _
62-
var kvClient: KV = _
63-
var lockClient: Lock = _
64-
var leaseClient: Lease = _
65-
var serviceNode: ServiceNode = _
61+
@volatile var client: Client = _
62+
@volatile var kvClient: KV = _
63+
@volatile var lockClient: Lock = _
64+
@volatile var leaseClient: Lease = _
65+
@volatile var serviceNode: ServiceNode = _
6666

67-
var leaseTTL: Long = _
67+
@volatile var leaseTTL: Long = _
6868

6969
private def buildClient(): Client = {
7070
val endpoints = conf.get(HA_ADDRESSES).split(",")
@@ -250,7 +250,7 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends DiscoveryClient {
250250
val instance = serviceDiscovery.fe.connectionUrl
251251
val watcher = new DeRegisterWatcher(instance, serviceDiscovery)
252252

253-
val serviceNode = createPersistentNode(
253+
serviceNode = createPersistentNode(
254254
conf,
255255
namespace,
256256
instance,

0 commit comments

Comments
 (0)