Skip to content

Commit 249700d

Browse files
committed
* Removed check the node is available for table service sessions
1 parent 2c64828 commit 249700d

File tree

5 files changed

+25
-43
lines changed

5 files changed

+25
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* Diabled check the node is available for query service session
1+
* Removed check the node is available for query and table service sessions
22

33
## v3.74.2
44
* Added description to scan errors with use query service client scanner

internal/table/client.go

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,34 @@ import (
2525
// sessionBuilder is the interface that holds logic of creating sessions.
2626
type sessionBuilder func(ctx context.Context) (*session, error)
2727

28-
type nodeChecker interface {
29-
HasNode(id uint32) bool
30-
}
31-
32-
type balancer interface {
33-
grpc.ClientConnInterface
34-
nodeChecker
35-
}
36-
37-
func New(ctx context.Context, balancer balancer, config *config.Config) *Client {
28+
func New(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config) *Client {
3829
onDone := trace.TableOnInit(config.Trace(), &ctx,
3930
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/table.New"),
4031
)
4132
defer func() {
4233
onDone(config.SizeLimit())
4334
}()
4435

45-
return newClient(ctx, balancer, func(ctx context.Context) (s *session, err error) {
46-
return newSession(ctx, balancer, config)
36+
return newClient(ctx, cc, func(ctx context.Context) (s *session, err error) {
37+
return newSession(ctx, cc, config)
4738
}, config)
4839
}
4940

5041
func newClient(
5142
ctx context.Context,
52-
balancer balancer,
43+
cc grpc.ClientConnInterface,
5344
builder sessionBuilder,
5445
config *config.Config,
5546
) *Client {
5647
c := &Client{
57-
clock: config.Clock(),
58-
config: config,
59-
cc: balancer,
60-
nodeChecker: balancer,
61-
build: builder,
62-
index: make(map[*session]sessionInfo),
63-
idle: list.New(),
64-
waitQ: list.New(),
65-
limit: config.SizeLimit(),
48+
clock: config.Clock(),
49+
config: config,
50+
cc: cc,
51+
build: builder,
52+
index: make(map[*session]sessionInfo),
53+
idle: list.New(),
54+
waitQ: list.New(),
55+
limit: config.SizeLimit(),
6656
waitChPool: sync.Pool{
6757
New: func() interface{} {
6858
ch := make(chan *session)
@@ -84,11 +74,10 @@ func newClient(
8474
// A Client is safe for use by multiple goroutines simultaneously.
8575
type Client struct {
8676
// read-only fields
87-
config *config.Config
88-
build sessionBuilder
89-
cc grpc.ClientConnInterface
90-
nodeChecker nodeChecker
91-
clock clockwork.Clock
77+
config *config.Config
78+
build sessionBuilder
79+
cc grpc.ClientConnInterface
80+
clock clockwork.Clock
9281

9382
// read-write fields
9483
mu xsync.Mutex
@@ -404,7 +393,7 @@ func (c *Client) internalPoolGet(ctx context.Context, opts ...getOption) (s *ses
404393
i++
405394
s = tryGetIdleSession(c)
406395
if s != nil {
407-
if !isValidNode(c, s) {
396+
if !s.isReady() {
408397
closeInvalidSession(ctx, s)
409398
s = nil
410399

@@ -437,11 +426,6 @@ func tryGetIdleSession(c *Client) *session {
437426
return s
438427
}
439428

440-
//nolint:interfacer
441-
func isValidNode(c *Client, s *session) bool {
442-
return c.nodeChecker == nil || c.nodeChecker.HasNode(s.NodeID())
443-
}
444-
445429
func closeInvalidSession(ctx context.Context, s *session) {
446430
_ = s.Close(ctx)
447431
}
@@ -599,9 +583,6 @@ func (c *Client) Put(ctx context.Context, s *session) (err error) {
599583
case s.isClosed():
600584
return xerrors.WithStackTrace(errSessionClosed)
601585

602-
case c.nodeChecker != nil && !c.nodeChecker.HasNode(s.NodeID()):
603-
return xerrors.WithStackTrace(errNodeIsNotObservable)
604-
605586
default:
606587
c.mu.Lock()
607588
defer c.mu.Unlock()

internal/table/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,17 +868,17 @@ type StubBuilder struct {
868868

869869
func newClientWithStubBuilder(
870870
t testing.TB,
871-
balancer balancer,
871+
cc grpc.ClientConnInterface,
872872
stubLimit int,
873873
options ...config.Option,
874874
) *Client {
875875
c := newClient(
876876
context.Background(),
877-
balancer,
877+
cc,
878878
(&StubBuilder{
879879
T: t,
880880
Limit: stubLimit,
881-
cc: balancer,
881+
cc: cc,
882882
}).createSession,
883883
config.New(options...),
884884
)

internal/table/errors.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ var (
3232
// operation could not be completed.
3333
errNoProgress = xerrors.Wrap(errors.New("no progress"))
3434

35-
// errNodeIsNotObservable returned by a Client instance to indicate that required node is not observable
36-
errNodeIsNotObservable = xerrors.Wrap(errors.New("node is not observable"))
37-
3835
// errParamsRequired returned by a Client instance to indicate that required params is not defined
3936
errParamsRequired = xerrors.Wrap(errors.New("params required"))
4037
)

internal/table/session.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func (s *session) isClosing() bool {
113113
return s.Status() == table.SessionClosing
114114
}
115115

116+
func (s *session) isReady() bool {
117+
return s.Status() == table.SessionReady
118+
}
119+
116120
func newSession(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config) (
117121
s *session, err error,
118122
) {

0 commit comments

Comments
 (0)