mirror of https://github.com/milvus-io/milvus.git
Fix retryKeepAlive assertion panic (#24667)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/24682/head
parent
f97127ae55
commit
d0c2fa5d19
|
@ -794,7 +794,7 @@ func (s *Session) LivenessCheck(ctx context.Context, callback func()) {
|
||||||
case mvccpb.PUT:
|
case mvccpb.PUT:
|
||||||
log.Info("register session success", zap.String("role", s.ServerName), zap.String("key", string(event.Kv.Key)))
|
log.Info("register session success", zap.String("role", s.ServerName), zap.String("key", string(event.Kv.Key)))
|
||||||
case mvccpb.DELETE:
|
case mvccpb.DELETE:
|
||||||
if s.retryKeepAlive.Load().(bool) {
|
if s.isRetryingKeepAlive() {
|
||||||
log.Info("session key is deleted during re register, ignore this DELETE event", zap.String("role", s.ServerName), zap.String("key", string(event.Kv.Key)))
|
log.Info("session key is deleted during re register, ignore this DELETE event", zap.String("role", s.ServerName), zap.String("key", string(event.Kv.Key)))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -873,6 +873,14 @@ func (s *Session) SetEnableRetryKeepAlive(enable bool) {
|
||||||
s.enableRetryKeepAlive = enable
|
s.enableRetryKeepAlive = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) isRetryingKeepAlive() bool {
|
||||||
|
v, ok := s.retryKeepAlive.Load().(bool)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) safeCloseLiveCh() {
|
func (s *Session) safeCloseLiveCh() {
|
||||||
s.liveChOnce.Do(func() {
|
s.liveChOnce.Do(func() {
|
||||||
close(s.liveCh)
|
close(s.liveCh)
|
||||||
|
|
|
@ -797,6 +797,29 @@ func (s *SessionSuite) TestDisconnected() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SessionSuite) TestRetryKeepAlive() {
|
||||||
|
st := &Session{}
|
||||||
|
st.retryKeepAlive.Store(true)
|
||||||
|
sf := &Session{}
|
||||||
|
sf.retryKeepAlive.Store(false)
|
||||||
|
|
||||||
|
cases := []struct {
|
||||||
|
tag string
|
||||||
|
input *Session
|
||||||
|
expect bool
|
||||||
|
}{
|
||||||
|
{"not_set", &Session{}, false},
|
||||||
|
{"set_true", st, true},
|
||||||
|
{"set_false", sf, false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range cases {
|
||||||
|
s.Run(c.tag, func() {
|
||||||
|
s.Equal(c.expect, c.input.isRetryingKeepAlive())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SessionSuite) TestGoingStop() {
|
func (s *SessionSuite) TestGoingStop() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
sdisconnect := NewSession(ctx, s.metaRoot, s.client)
|
sdisconnect := NewSession(ctx, s.metaRoot, s.client)
|
||||||
|
|
Loading…
Reference in New Issue