mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
fix: write buffer leak if the wal flusher is cancelled when recovery (#41719)
issue: #41715 Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
parent
ff5c2770e5
commit
452d6fb709
@ -168,13 +168,24 @@ func (impl *flusherComponents) recover(ctx context.Context, recoverInfos map[str
|
|||||||
futures[vchannel] = future
|
futures[vchannel] = future
|
||||||
}
|
}
|
||||||
dataServices := make(map[string]*dataSyncServiceWrapper, len(futures))
|
dataServices := make(map[string]*dataSyncServiceWrapper, len(futures))
|
||||||
|
var lastErr error
|
||||||
for vchannel, future := range futures {
|
for vchannel, future := range futures {
|
||||||
ds, err := future.Await()
|
ds, err := future.Await()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
lastErr = err
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
dataServices[vchannel] = ds.(*dataSyncServiceWrapper)
|
dataServices[vchannel] = ds.(*dataSyncServiceWrapper)
|
||||||
}
|
}
|
||||||
|
if lastErr != nil {
|
||||||
|
// release all the data sync services if operation is canceled.
|
||||||
|
// otherwise, the write buffer will leak.
|
||||||
|
for _, ds := range dataServices {
|
||||||
|
ds.Close()
|
||||||
|
}
|
||||||
|
impl.logger.Warn("failed to build data sync service, may be canceled when recovering", zap.Error(lastErr))
|
||||||
|
return lastErr
|
||||||
|
}
|
||||||
impl.dataServices = dataServices
|
impl.dataServices = dataServices
|
||||||
for vchannel, ds := range dataServices {
|
for vchannel, ds := range dataServices {
|
||||||
ds.Start()
|
ds.Start()
|
||||||
|
|||||||
@ -29,7 +29,7 @@ func RecoverWALFlusher(param *interceptors.InterceptorBuildParam) *WALFlusherImp
|
|||||||
wal: param.WAL,
|
wal: param.WAL,
|
||||||
logger: resource.Resource().Logger().With(
|
logger: resource.Resource().Logger().With(
|
||||||
log.FieldComponent("flusher"),
|
log.FieldComponent("flusher"),
|
||||||
zap.String("pchannel", param.ChannelInfo.Name)),
|
zap.String("pchannel", param.ChannelInfo.String())),
|
||||||
metrics: newFlusherMetrics(param.ChannelInfo),
|
metrics: newFlusherMetrics(param.ChannelInfo),
|
||||||
}
|
}
|
||||||
go flusher.Execute()
|
go flusher.Execute()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user