Skip to content

Commit 548257a

Browse files
committed
fixes of getting session from closing table client
1 parent c26ec29 commit 548257a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/table/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ func (c *Client) internalPoolGet(ctx context.Context, opts ...getOption) (s *ses
352352
}()
353353

354354
const maxAttempts = 100
355-
for ; s == nil && err == nil && i < maxAttempts; i++ {
356-
if c.isClosed() {
357-
return nil, xerrors.WithStackTrace(errClosedClient)
358-
}
359-
355+
for ; s == nil && err == nil && i < maxAttempts && !c.isClosed(); i++ {
360356
// First, we try to internalPoolGet session from idle
361357
c.mu.WithLock(func() {
362358
s = c.internalPoolRemoveFirstIdle()
@@ -391,7 +387,11 @@ func (c *Client) internalPoolGet(ctx context.Context, opts ...getOption) (s *ses
391387
}
392388
}
393389
if s == nil && err == nil {
394-
err = xerrors.WithStackTrace(errNoProgress)
390+
if c.isClosed() {
391+
err = xerrors.WithStackTrace(errClosedClient)
392+
} else {
393+
err = xerrors.WithStackTrace(errNoProgress)
394+
}
395395
}
396396
if err != nil {
397397
var (

0 commit comments

Comments
 (0)