Skip to content

Commit a938edb

Browse files
committed
clone the config
1 parent fedff39 commit a938edb

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@ func (opt *Options) init() {
347347

348348
func (opt *Options) clone() *Options {
349349
clone := *opt
350+
351+
// Deep clone HitlessUpgradeConfig to avoid sharing between clients
352+
if opt.HitlessUpgradeConfig != nil {
353+
configClone := *opt.HitlessUpgradeConfig
354+
clone.HitlessUpgradeConfig = &configClone
355+
}
356+
350357
return &clone
351358
}
352359

osscluster.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ func setupClusterQueryParams(u *url.URL, o *ClusterOptions) (*ClusterOptions, er
328328
}
329329

330330
func (opt *ClusterOptions) clientOptions() *Options {
331+
// Clone HitlessUpgradeConfig to avoid sharing between cluster node clients
332+
var hitlessConfig *HitlessUpgradeConfig
333+
if opt.HitlessUpgradeConfig != nil {
334+
configClone := *opt.HitlessUpgradeConfig
335+
hitlessConfig = &configClone
336+
}
337+
331338
return &Options{
332339
ClientName: opt.ClientName,
333340
Dialer: opt.Dialer,
@@ -371,7 +378,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
371378
// situations in the options below will prevent that from happening.
372379
readOnly: opt.ReadOnly && opt.ClusterSlots == nil,
373380
UnstableResp3: opt.UnstableResp3,
374-
HitlessUpgradeConfig: opt.HitlessUpgradeConfig,
381+
HitlessUpgradeConfig: hitlessConfig,
375382
}
376383
}
377384

tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Tx struct {
2424
func (c *Client) newTx() *Tx {
2525
tx := Tx{
2626
baseClient: baseClient{
27-
opt: c.opt,
27+
opt: c.opt.clone(), // Clone options to avoid sharing HitlessUpgradeConfig
2828
connPool: pool.NewStickyConnPool(c.connPool),
2929
hooksMixin: c.hooksMixin.clone(),
3030
pushProcessor: c.pushProcessor, // Copy push processor from parent client

0 commit comments

Comments
 (0)