Skip to content

Commit fe6fa01

Browse files
authored
Merge pull request #522 from ydb-platform/fix-wrap
* Fixed wrapping error in `internal/balancer/Balancer.wrapCall()`
2 parents 7ddd8ea + 7d7e77c commit fe6fa01

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Separated errors of commit from other reader and to expired session
2+
* Fixed wrapping error in `internal/balancer/Balancer.wrapCall()`
23

34
## v3.42.4
45
* Added `ydb.WithDisableServerBalancer()` database/sql connector option

internal/balancer/balancer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ func (b *Balancer) wrapCall(ctx context.Context, f func(ctx context.Context, cc
279279
}
280280

281281
if err = f(ctx, cc); err != nil {
282-
return xerrors.WithStackTrace(err)
282+
if conn.UseWrapping(ctx) {
283+
return xerrors.WithStackTrace(err)
284+
}
285+
return err
283286
}
284287

285288
return nil

internal/conn/conn.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ func (c *conn) Invoke(
297297
opts ...grpc.CallOption,
298298
) (err error) {
299299
var (
300-
opID string
301-
issues []trace.Issue
302-
wrapping = needWrapping(ctx)
303-
onDone = trace.DriverOnConnInvoke(
300+
opID string
301+
issues []trace.Issue
302+
useWrapping = UseWrapping(ctx)
303+
onDone = trace.DriverOnConnInvoke(
304304
c.config.Trace(),
305305
&ctx,
306306
c.endpoint,
@@ -330,7 +330,7 @@ func (c *conn) Invoke(
330330

331331
err = cc.Invoke(ctx, method, req, res, append(opts, grpc.Trailer(&md))...)
332332
if err != nil {
333-
if wrapping {
333+
if useWrapping {
334334
err = xerrors.FromGRPCError(err,
335335
xerrors.WithAddress(c.Address()),
336336
)
@@ -353,7 +353,7 @@ func (c *conn) Invoke(
353353
for _, issue := range o.GetOperation().GetIssues() {
354354
issues = append(issues, issue)
355355
}
356-
if wrapping {
356+
if useWrapping {
357357
switch {
358358
case !o.GetOperation().GetReady():
359359
return xerrors.WithStackTrace(errOperationNotReady)
@@ -386,9 +386,9 @@ func (c *conn) NewStream(
386386
c.endpoint.Copy(),
387387
trace.Method(method),
388388
)
389-
wrapping = needWrapping(ctx)
390-
cc *grpc.ClientConn
391-
s grpc.ClientStream
389+
useWrapping = UseWrapping(ctx)
390+
cc *grpc.ClientConn
391+
s grpc.ClientStream
392392
)
393393

394394
defer func() {
@@ -418,7 +418,7 @@ func (c *conn) NewStream(
418418

419419
s, err = cc.NewStream(ctx, desc, method, opts...)
420420
if err != nil {
421-
if wrapping {
421+
if useWrapping {
422422
err = xerrors.Retryable(
423423
xerrors.FromGRPCError(err,
424424
xerrors.WithAddress(c.Address()),
@@ -436,7 +436,7 @@ func (c *conn) NewStream(
436436
return &grpcClientStream{
437437
ClientStream: s,
438438
c: c,
439-
wrapping: wrapping,
439+
wrapping: useWrapping,
440440
sentMark: sentMark,
441441
onDone: func(ctx context.Context, md metadata.MD) {
442442
cancel()

internal/conn/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ func WithoutWrapping(ctx context.Context) context.Context {
88
return context.WithValue(ctx, ctxNoWrappingKey{}, true)
99
}
1010

11-
func needWrapping(ctx context.Context) bool {
11+
func UseWrapping(ctx context.Context) bool {
1212
b, ok := ctx.Value(ctxNoWrappingKey{}).(bool)
1313
return !ok || !b
1414
}

0 commit comments

Comments
 (0)