Skip to content

Commit f131241

Browse files
committed
* Removed ydb.WithSessionPoolSizeLimit() option
* Added async put session into pool if external context is done
1 parent 302f738 commit f131241

39 files changed

+442
-281
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Fixed logic of query session pool
55
* Changed initialization of internal driver clients to lazy
66
* Disabled the logic of background grpc-connection parking
7+
* Removed `ydb.WithSessionPoolSizeLimit()` option
8+
* Added async put session into pool if external context is done
79

810
## v3.58.2
911
* Added `trace.Query.OnSessionBegin` event

driver.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func New(ctx context.Context, opts ...Option) (_ *Driver, err error) {
300300

301301
//nolint:cyclop, nonamedreturns
302302
func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, err error) {
303-
ctx, driverCtxCancel := xcontext.WithCancel(xcontext.WithoutDeadline(ctx))
303+
ctx, driverCtxCancel := xcontext.WithCancel(xcontext.ValueOnly(ctx))
304304
defer func() {
305305
if err != nil {
306306
driverCtxCancel()
@@ -401,7 +401,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
401401
}
402402

403403
d.table = xsync.OnceValue(func() *internalTable.Client {
404-
return internalTable.New(xcontext.WithoutDeadline(ctx),
404+
return internalTable.New(xcontext.ValueOnly(ctx),
405405
d.balancer,
406406
tableConfig.New(
407407
append(
@@ -416,7 +416,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
416416
})
417417

418418
d.query = xsync.OnceValue(func() *internalQuery.Client {
419-
return internalQuery.New(xcontext.WithoutDeadline(ctx),
419+
return internalQuery.New(xcontext.ValueOnly(ctx),
420420
d.balancer,
421421
queryConfig.New(
422422
append(
@@ -434,7 +434,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
434434
}
435435

436436
d.scheme = xsync.OnceValue(func() *internalScheme.Client {
437-
return internalScheme.New(xcontext.WithoutDeadline(ctx),
437+
return internalScheme.New(xcontext.ValueOnly(ctx),
438438
d.balancer,
439439
schemeConfig.New(
440440
append(
@@ -450,7 +450,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
450450
})
451451

452452
d.coordination = xsync.OnceValue(func() *internalCoordination.Client {
453-
return internalCoordination.New(xcontext.WithoutDeadline(ctx),
453+
return internalCoordination.New(xcontext.ValueOnly(ctx),
454454
d.balancer,
455455
coordinationConfig.New(
456456
append(
@@ -465,7 +465,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
465465
})
466466

467467
d.ratelimiter = xsync.OnceValue(func() *internalRatelimiter.Client {
468-
return internalRatelimiter.New(xcontext.WithoutDeadline(ctx),
468+
return internalRatelimiter.New(xcontext.ValueOnly(ctx),
469469
d.balancer,
470470
ratelimiterConfig.New(
471471
append(
@@ -480,7 +480,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
480480
})
481481

482482
d.discovery = xsync.OnceValue(func() *internalDiscovery.Client {
483-
return internalDiscovery.New(xcontext.WithoutDeadline(ctx),
483+
return internalDiscovery.New(xcontext.ValueOnly(ctx),
484484
d.pool.Get(endpoint.New(d.config.Endpoint())),
485485
discoveryConfig.New(
486486
append(
@@ -499,7 +499,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
499499
})
500500

501501
d.scripting = xsync.OnceValue(func() *internalScripting.Client {
502-
return internalScripting.New(xcontext.WithoutDeadline(ctx),
502+
return internalScripting.New(xcontext.ValueOnly(ctx),
503503
d.balancer,
504504
scriptingConfig.New(
505505
append(
@@ -514,7 +514,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
514514
})
515515

516516
d.topic = xsync.OnceValue(func() *topicclientinternal.Client {
517-
return topicclientinternal.New(xcontext.WithoutDeadline(ctx),
517+
return topicclientinternal.New(xcontext.ValueOnly(ctx),
518518
d.balancer,
519519
d.config.Credentials(),
520520
append(

internal/balancer/balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func New(
280280
}
281281
// run background discovering
282282
if d := discoveryConfig.Interval(); d > 0 {
283-
b.discoveryRepeater = repeater.New(xcontext.WithoutDeadline(ctx),
283+
b.discoveryRepeater = repeater.New(xcontext.ValueOnly(ctx),
284284
d, b.clusterDiscoveryAttempt,
285285
repeater.WithName("discovery"),
286286
repeater.WithTrace(b.driverConfig.Trace()),

internal/conn/grpc_client_stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (s *grpcClientStream) RecvMsg(m interface{}) (err error) {
105105

106106
err = s.ClientStream.RecvMsg(m)
107107

108-
if err != nil {
108+
if err != nil { //nolint:nestif
109109
if xerrors.IsContextError(err) {
110110
return xerrors.WithStackTrace(err)
111111
}

internal/conn/pool.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ func (p *Pool) Ban(ctx context.Context, cc Conn, cause error) {
8181
if !xerrors.IsTransportError(cause,
8282
grpcCodes.ResourceExhausted,
8383
grpcCodes.Unavailable,
84-
//grpcCodes.OK,
85-
//grpcCodes.Canceled,
86-
//grpcCodes.Unknown,
87-
//grpcCodes.InvalidArgument,
88-
//grpcCodes.DeadlineExceeded,
89-
//grpcCodes.NotFound,
90-
//grpcCodes.AlreadyExists,
91-
//grpcCodes.PermissionDenied,
92-
//grpcCodes.FailedPrecondition,
93-
//grpcCodes.Aborted,
94-
//grpcCodes.OutOfRange,
95-
//grpcCodes.Unimplemented,
96-
//grpcCodes.Internal,
97-
//grpcCodes.DataLoss,
98-
//grpcCodes.Unauthenticated,
84+
// grpcCodes.OK,
85+
// grpcCodes.Canceled,
86+
// grpcCodes.Unknown,
87+
// grpcCodes.InvalidArgument,
88+
// grpcCodes.DeadlineExceeded,
89+
// grpcCodes.NotFound,
90+
// grpcCodes.AlreadyExists,
91+
// grpcCodes.PermissionDenied,
92+
// grpcCodes.FailedPrecondition,
93+
// grpcCodes.Aborted,
94+
// grpcCodes.OutOfRange,
95+
// grpcCodes.Unimplemented,
96+
// grpcCodes.Internal,
97+
// grpcCodes.DataLoss,
98+
// grpcCodes.Unauthenticated,
9999
) {
100100
return
101101
}

0 commit comments

Comments
 (0)