Skip to content

Commit b7d2de8

Browse files
committed
check context before call
1 parent dd9f27b commit b7d2de8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

internal/query/session_core.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ func (core *sessionCore) deleteSession(ctx context.Context) (finalErr error) {
240240
defer cancel()
241241
}
242242

243+
if err := ctx.Err(); err != nil {
244+
return xerrors.WithStackTrace(err)
245+
}
246+
243247
_, err := core.Client.DeleteSession(ctx,
244248
&Ydb_Query.DeleteSessionRequest{
245249
SessionId: core.id,

internal/table/session.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ func newTableSession( //nolint:funlen
357357
status: table.SessionReady,
358358
onClose: []func(s *Session) error{
359359
func(s *Session) error {
360+
if err := ctx.Err(); err != nil {
361+
return xerrors.WithStackTrace(err)
362+
}
363+
360364
_, err = s.client.DeleteSession(ctx,
361365
&Ydb_Table.DeleteSessionRequest{
362366
SessionId: s.id,
@@ -471,13 +475,13 @@ func (s *Session) ID() string {
471475
return s.id
472476
}
473477

474-
func (s *Session) Close(ctx context.Context) (err error) {
478+
func (s *Session) Close(ctx context.Context) (finalErr error) {
475479
onDone := trace.TableOnSessionDelete(s.config.Trace(), &ctx,
476480
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*Session).Close"),
477481
s,
478482
)
479483
defer func() {
480-
onDone(err)
484+
onDone(finalErr)
481485
s.SetStatus(table.SessionClosed)
482486
}()
483487

0 commit comments

Comments
 (0)