mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: wal may panics when context canceled (#40265)
issue: #40264 - wal may panics when context canceled - scanner may data race when closing Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
parent
9a8d94998a
commit
2ff657f2d9
@ -98,7 +98,9 @@ func (s *scannerAdaptorImpl) execute() {
|
||||
s.logger.Info("scanner start background task")
|
||||
|
||||
msgChan := make(chan message.ImmutableMessage)
|
||||
|
||||
ch := make(chan struct{})
|
||||
defer func() { <-ch }()
|
||||
// TODO: optimize the extra goroutine here after msgstream is removed.
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -116,9 +118,6 @@ func (s *scannerAdaptorImpl) execute() {
|
||||
return
|
||||
}
|
||||
s.logger.Warn("the consuming event loop of scanner is closed with unexpected error", zap.Error(err))
|
||||
|
||||
// waiting for the produce event loop to close.
|
||||
<-ch
|
||||
}
|
||||
|
||||
// produceEventLoop produces the message from the wal and write ahead buffer.
|
||||
|
||||
@ -41,10 +41,14 @@ func (impl *timeTickAppendInterceptor) Ready() <-chan struct{} {
|
||||
|
||||
// Do implements AppendInterceptor.
|
||||
func (impl *timeTickAppendInterceptor) DoAppend(ctx context.Context, msg message.MutableMessage, append interceptors.Append) (msgID message.MessageID, err error) {
|
||||
cm, err := impl.operator.MVCCManager(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err == nil {
|
||||
// the cursor manager should beready since the timetick interceptor is ready.
|
||||
cm, _ := impl.operator.MVCCManager(ctx)
|
||||
cm.UpdateMVCC(msg)
|
||||
}
|
||||
}()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user