From b8474db57b11abb0e0dcb15082aa33db1c786f9c Mon Sep 17 00:00:00 2001 From: Roman Golov Date: Thu, 18 Apr 2024 21:40:33 +0300 Subject: [PATCH 1/2] Fix data race in grpc Client stream. --- CHANGELOG.md | 2 ++ internal/conn/grpc_client_stream.go | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c5bd059a..ab9c9c2d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Fixed data race in `grpcClientStream` + ## v3.65.2 * Fixed data race using `log.WithNames` diff --git a/internal/conn/grpc_client_stream.go b/internal/conn/grpc_client_stream.go index 32377e5ab..96ab744fc 100644 --- a/internal/conn/grpc_client_stream.go +++ b/internal/conn/grpc_client_stream.go @@ -25,7 +25,8 @@ type grpcClientStream struct { } func (s *grpcClientStream) CloseSend() (err error) { - onDone := trace.DriverOnConnStreamCloseSend(s.c.config.Trace(), &s.ctx, + ctx := s.ctx + onDone := trace.DriverOnConnStreamCloseSend(s.c.config.Trace(), &ctx, stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).CloseSend"), ) defer func() { @@ -59,7 +60,8 @@ func (s *grpcClientStream) CloseSend() (err error) { } func (s *grpcClientStream) SendMsg(m interface{}) (err error) { - onDone := trace.DriverOnConnStreamSendMsg(s.c.config.Trace(), &s.ctx, + ctx := s.ctx + onDone := trace.DriverOnConnStreamSendMsg(s.c.config.Trace(), &ctx, stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).SendMsg"), ) defer func() { @@ -101,7 +103,8 @@ func (s *grpcClientStream) SendMsg(m interface{}) (err error) { } func (s *grpcClientStream) RecvMsg(m interface{}) (err error) { - onDone := trace.DriverOnConnStreamRecvMsg(s.c.config.Trace(), &s.ctx, + ctx := s.ctx + onDone := trace.DriverOnConnStreamRecvMsg(s.c.config.Trace(), &ctx, stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).RecvMsg"), ) defer func() { @@ -114,7 +117,7 @@ func (s *grpcClientStream) RecvMsg(m interface{}) (err error) { defer func() { if err != nil { md := s.ClientStream.Trailer() - s.onDone(s.ctx, md) + s.onDone(ctx, md) } }() From ecc181139d2a3e2d894943be35ae2f23e6a3efa2 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Thu, 18 Apr 2024 23:48:54 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab9c9c2d9..796256177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -* Fixed data race in `grpcClientStream` +* Fixed data race in `internal/conn.grpcClientStream` ## v3.65.2 * Fixed data race using `log.WithNames`