Skip to content

Commit 1e11a72

Browse files
authored
Merge pull request #1833 from dcherednik/disable_optimistic_unban
Disable optimistic unban nodes after pessimization
2 parents 84bbd8f + d646fab commit 1e11a72

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Added experimental config.WithDisableOptimisticUnban to disable fast node unban after pessimization
12
* Fixed respect start offset from topicoptions.WithReaderGetPartitionStartOffset for commit messages
23
* Added `query.AllowImplicitSessions()` option for execute queries through `query.Client.{Exec,Query,QueryResultSet,QueryRow}` without explicit sessions
34

config/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Config struct {
3535
meta *meta.Meta
3636

3737
excludeGRPCCodesForPessimization []grpcCodes.Code
38+
disableOptimisticUnban bool
3839
}
3940

4041
func (c *Config) Credentials() credentials.Credentials {
@@ -46,6 +47,10 @@ func (c *Config) ExcludeGRPCCodesForPessimization() []grpcCodes.Code {
4647
return c.excludeGRPCCodesForPessimization
4748
}
4849

50+
func (c *Config) DisableOptimisticUnban() bool {
51+
return c.disableOptimisticUnban
52+
}
53+
4954
// GrpcDialOptions reports about used grpc dialing options
5055
func (c *Config) GrpcDialOptions() []grpc.DialOption {
5156
return append(
@@ -306,6 +311,16 @@ func ExcludeGRPCCodesForPessimization(codes ...grpcCodes.Code) Option {
306311
}
307312
}
308313

314+
// WithDisableOptimisticUnban disables optimistic unban of nodes after a successful call
315+
// immediately following pessimization.
316+
//
317+
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
318+
func WithDisableOptimisticUnban() Option {
319+
return func(c *Config) {
320+
c.disableOptimisticUnban = true
321+
}
322+
}
323+
309324
func New(opts ...Option) *Config {
310325
c := defaultConfig()
311326

internal/balancer/balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (b *Balancer) wrapCall(ctx context.Context, f func(ctx context.Context, cc
372372

373373
defer func() {
374374
if err == nil {
375-
if cc.GetState() == conn.Banned {
375+
if !b.driverConfig.DisableOptimisticUnban() && cc.GetState() == conn.Banned {
376376
b.pool.Allow(ctx, cc)
377377
}
378378
} else if conn.IsBadConn(err, b.driverConfig.ExcludeGRPCCodesForPessimization()...) {

0 commit comments

Comments
 (0)