From 369b60f86fcf0c2c3281de3df7ea501c11e1cb17 Mon Sep 17 00:00:00 2001 From: SimFG Date: Wed, 4 Dec 2024 15:14:25 +0800 Subject: [PATCH] support to ignore error when delete a task --- core/reader/replicate_channel_manager.go | 3 +++ server/cdc_impl.go | 3 +++ server/model/request/delete.go | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/reader/replicate_channel_manager.go b/core/reader/replicate_channel_manager.go index b48588a6..891ed801 100644 --- a/core/reader/replicate_channel_manager.go +++ b/core/reader/replicate_channel_manager.go @@ -573,6 +573,9 @@ func (r *replicateChannelManager) AddPartition(ctx context.Context, dbInfo *mode func (r *replicateChannelManager) StopReadCollection(ctx context.Context, info *pb.CollectionInfo) error { for _, channel := range info.GetPhysicalChannelNames() { handler := r.stopReadChannel(channel, info.ID) + if handler == nil { + continue + } handler.Close() } r.collectionLock.Lock() diff --git a/server/cdc_impl.go b/server/cdc_impl.go index caa2b9a6..e9369cd0 100644 --- a/server/cdc_impl.go +++ b/server/cdc_impl.go @@ -1248,6 +1248,9 @@ func (e *MetaCDC) Delete(req *request.DeleteRequest) (*request.DeleteResponse, e _, ok := e.cdcTasks.data[req.TaskID] e.cdcTasks.RUnlock() if !ok { + if req.IgnoreNotFound { + return &request.DeleteResponse{}, nil + } return nil, servererror.NewClientError("not found the task, task_id: " + req.TaskID) } diff --git a/server/model/request/delete.go b/server/model/request/delete.go index 9bb4244f..fe7a7ca8 100644 --- a/server/model/request/delete.go +++ b/server/model/request/delete.go @@ -20,7 +20,8 @@ package request //go:generate easytags $GOFILE json,mapstructure type DeleteRequest struct { - TaskID string `json:"task_id" mapstructure:"task_id"` + TaskID string `json:"task_id" mapstructure:"task_id"` + IgnoreNotFound bool `json:"ignore_not_found" mapstructure:"ignore_not_found"` } type DeleteResponse struct{}