Skip to content

Commit

Permalink
[KYUUBI #6048] Assign serviceNode and add volatile for variables
Browse files Browse the repository at this point in the history
# 🔍 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 <[email protected]>
Signed-off-by: wforget <[email protected]>
(cherry picked from commit 19c0576)
Signed-off-by: wforget <[email protected]>
  • Loading branch information
wForget committed Feb 8, 2024
1 parent e43ddb8 commit 5dca0e0
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5dca0e0

Please sign in to comment.