Skip to content

Commit 2ef18c5

Browse files
authored
enhance: remove watch at session liveness check (#45968)
issue: #45724 --------- Signed-off-by: chyezh <[email protected]>
1 parent af734f1 commit 2ef18c5

File tree

12 files changed

+212
-693
lines changed

12 files changed

+212
-693
lines changed

cmd/tools/migration/migration/runner.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ func (r *Runner) CheckSessions() error {
165165

166166
func (r *Runner) RegisterSession() error {
167167
r.session.Register()
168-
r.session.LivenessCheck(r.ctx, func() {})
169168
return nil
170169
}
171170

@@ -246,7 +245,7 @@ func (r *Runner) waitUntilSessionExpired() {
246245
}
247246

248247
func (r *Runner) Stop() {
249-
r.session.Revoke(time.Second)
248+
r.session.Stop()
250249
r.waitUntilSessionExpired()
251250
r.cancel()
252251
r.wg.Wait()

internal/coordinator/mix_coord.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ func (s *mixCoordImpl) Register() error {
114114
afterRegister := func() {
115115
metrics.NumNodes.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), typeutil.MixCoordRole).Inc()
116116
log.Info("MixCoord Register Finished")
117-
s.session.LivenessCheck(s.ctx, func() {
118-
log.Error("MixCoord disconnected from etcd, process will exit", zap.Int64("serverID", s.session.GetServerID()))
119-
os.Exit(1)
120-
})
121117
}
122118
if s.enableActiveStandBy {
123119
go func() {

internal/datanode/data_node.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"fmt"
2525
"io"
2626
"math/rand"
27-
"os"
2827
"sync"
2928
"time"
3029

@@ -157,12 +156,6 @@ func (node *DataNode) Register() error {
157156

158157
metrics.NumNodes.WithLabelValues(fmt.Sprint(node.GetNodeID()), typeutil.DataNodeRole).Inc()
159158
log.Info("DataNode Register Finished")
160-
// Start liveness check
161-
node.session.LivenessCheck(node.ctx, func() {
162-
log.Error("Data Node disconnected from etcd, process will exit", zap.Int64("Server Id", node.GetSession().ServerID))
163-
os.Exit(1)
164-
})
165-
166159
return nil
167160
}
168161

internal/distributed/streamingnode/service.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package streamingnode
1818

1919
import (
2020
"context"
21-
"os"
2221
"strconv"
2322
"sync"
2423
"time"
@@ -251,7 +250,7 @@ func (s *Server) start() (err error) {
251250
return errors.Wrap(err, "StreamingNode start gRPC server fail")
252251
}
253252
// Register current server to etcd.
254-
s.registerSessionToETCD()
253+
s.session.Register()
255254

256255
s.componentState.OnInitialized(s.session.ServerID)
257256
return nil
@@ -382,13 +381,3 @@ func (s *Server) startGPRCServer(ctx context.Context) error {
382381
funcutil.CheckGrpcReady(ctx, errCh)
383382
return <-errCh
384383
}
385-
386-
// registerSessionToETCD registers current server to etcd.
387-
func (s *Server) registerSessionToETCD() {
388-
s.session.Register()
389-
// start liveness check
390-
s.session.LivenessCheck(context.Background(), func() {
391-
log.Ctx(s.ctx).Error("StreamingNode disconnected from etcd, process will exit", zap.Int64("Server Id", paramtable.GetNodeID()))
392-
os.Exit(1)
393-
})
394-
}

internal/proxy/proxy.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"fmt"
2222
"math/rand"
23-
"os"
2423
"sync"
2524
"time"
2625

@@ -157,10 +156,6 @@ func (node *Proxy) Register() error {
157156
node.session.Register()
158157
metrics.NumNodes.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), typeutil.ProxyRole).Inc()
159158
log.Info("Proxy Register Finished")
160-
node.session.LivenessCheck(node.ctx, func() {
161-
log.Error("Proxy disconnected from etcd, process will exit", zap.Int64("Server Id", node.session.ServerID))
162-
os.Exit(1)
163-
})
164159
// TODO Reset the logger
165160
// Params.initLogCfg()
166161
return nil

internal/querycoordv2/mocks/querynode.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"net"
2222
"sync"
2323
"testing"
24-
"time"
2524

2625
"github.com/stretchr/testify/mock"
2726
clientv3 "go.etcd.io/etcd/client/v3"
@@ -149,7 +148,7 @@ func (node *MockQueryNode) Stopping() {
149148
func (node *MockQueryNode) Stop() {
150149
node.cancel()
151150
node.server.GracefulStop()
152-
node.session.Revoke(time.Second)
151+
node.session.Stop()
153152
}
154153

155154
func (node *MockQueryNode) getAllChannels() []*querypb.ChannelVersionInfo {

internal/querynodev2/server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import "C"
3232
import (
3333
"context"
3434
"fmt"
35-
"os"
3635
"plugin"
3736
"strings"
3837
"sync"
@@ -182,10 +181,6 @@ func (node *QueryNode) Register() error {
182181
node.session.Register()
183182
// start liveness check
184183
metrics.NumNodes.WithLabelValues(fmt.Sprint(node.GetNodeID()), typeutil.QueryNodeRole).Inc()
185-
node.session.LivenessCheck(node.ctx, func() {
186-
log.Ctx(node.ctx).Error("Query Node disconnected from etcd, process will exit", zap.Int64("Server Id", paramtable.GetNodeID()))
187-
os.Exit(1)
188-
})
189184
return nil
190185
}
191186

internal/util/sessionutil/mock_session.go

Lines changed: 0 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/util/sessionutil/session.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
package sessionutil
1717

1818
import (
19-
"context"
20-
"time"
21-
2219
"github.com/blang/semver/v4"
2320
)
2421

@@ -36,9 +33,7 @@ type SessionInterface interface {
3633
GoingStop() error
3734
WatchServices(prefix string, revision int64, rewatch Rewatch) (watcher SessionWatcher)
3835
WatchServicesWithVersionRange(prefix string, r semver.Range, revision int64, rewatch Rewatch) (watcher SessionWatcher)
39-
LivenessCheck(ctx context.Context, callback func())
4036
Stop()
41-
Revoke(timeout time.Duration)
4237
UpdateRegistered(b bool)
4338
Registered() bool
4439
SetDisconnected(b bool)

0 commit comments

Comments
 (0)