Skip to content

Commit e4883a5

Browse files
committed
store/bigtable: fix grpc error on close
1 parent 02926ed commit e4883a5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

db2/store/bigtable.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"context"
55
"fmt"
66
"slices"
7-
"strings"
87
"time"
98

109
"cloud.google.com/go/bigtable"
1110
"golang.org/x/exp/maps"
11+
"google.golang.org/grpc/codes"
12+
"google.golang.org/grpc/status"
1213
)
1314

1415
var ErrNotFound = fmt.Errorf("not found")
@@ -324,14 +325,13 @@ func (b BigTableStore) Clear() error {
324325
// Close shuts down the BigTableStore by closing the Bigtable client connection
325326
// It returns an error if the operation fails
326327
func (b BigTableStore) Close() error {
327-
if err := b.client.Close(); err != nil {
328+
if err := b.client.Close(); err != nil && status.Code(err) != codes.Canceled {
328329
return fmt.Errorf("could not close client: %v", err)
329330
}
330-
if err := b.admin.Close(); err != nil {
331-
if !strings.Contains(err.Error(), "the client connection is closing") {
331+
if b.admin != nil {
332+
if err := b.admin.Close(); err != nil && status.Code(err) != codes.Canceled {
332333
return fmt.Errorf("could not close admin client: %v", err)
333334
}
334335
}
335-
336336
return nil
337337
}

0 commit comments

Comments
 (0)