diff --git a/internal/rootcoord/create_alias_task.go b/internal/rootcoord/create_alias_task.go index d7e2e69b09..b999944805 100644 --- a/internal/rootcoord/create_alias_task.go +++ b/internal/rootcoord/create_alias_task.go @@ -21,6 +21,9 @@ func (t *createAliasTask) Prepare(ctx context.Context) error { } func (t *createAliasTask) Execute(ctx context.Context) error { + if err := t.core.ExpireMetaCache(ctx, []string{t.Req.GetAlias(), t.Req.GetCollectionName()}, InvalidCollectionID, t.GetTs()); err != nil { + return err + } // create alias is atomic enough. return t.core.meta.CreateAlias(ctx, t.Req.GetAlias(), t.Req.GetCollectionName(), t.GetTs()) } diff --git a/internal/rootcoord/create_alias_task_test.go b/internal/rootcoord/create_alias_task_test.go index 9150d3f647..8e6a6a3d93 100644 --- a/internal/rootcoord/create_alias_task_test.go +++ b/internal/rootcoord/create_alias_task_test.go @@ -25,8 +25,21 @@ func Test_createAliasTask_Prepare(t *testing.T) { } func Test_createAliasTask_Execute(t *testing.T) { + t.Run("failed to expire cache", func(t *testing.T) { + core := newTestCore(withInvalidProxyManager()) + task := &createAliasTask{ + baseTask: baseTask{core: core}, + Req: &milvuspb.CreateAliasRequest{ + Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateAlias}, + Alias: "test", + }, + } + err := task.Execute(context.Background()) + assert.Error(t, err) + }) + t.Run("failed to create alias", func(t *testing.T) { - core := newTestCore(withInvalidMeta()) + core := newTestCore(withInvalidMeta(), withValidProxyManager()) task := &createAliasTask{ baseTask: baseTask{core: core}, Req: &milvuspb.CreateAliasRequest{ diff --git a/internal/rootcoord/create_collection_task.go b/internal/rootcoord/create_collection_task.go index 7023fda8da..5013d2054f 100644 --- a/internal/rootcoord/create_collection_task.go +++ b/internal/rootcoord/create_collection_task.go @@ -271,6 +271,12 @@ func (t *createCollectionTask) Execute(ctx context.Context) error { } undoTask := newBaseUndoTask(t.core.stepExecutor) + undoTask.AddStep(&expireCacheStep{ + baseStep: baseStep{core: t.core}, + collectionNames: []string{t.Req.GetCollectionName()}, + collectionID: InvalidCollectionID, + ts: ts, + }, &nullStep{}) undoTask.AddStep(&nullStep{}, &removeDmlChannelsStep{ baseStep: baseStep{core: t.core}, pChannels: chanNames, diff --git a/internal/rootcoord/create_collection_task_test.go b/internal/rootcoord/create_collection_task_test.go index f5679f187a..fa0ffd8e31 100644 --- a/internal/rootcoord/create_collection_task_test.go +++ b/internal/rootcoord/create_collection_task_test.go @@ -397,6 +397,7 @@ func Test_createCollectionTask_Execute(t *testing.T) { core := newTestCore(withValidIDAllocator(), withMeta(meta), withTtSynchronizer(ticker), + withValidProxyManager(), withDataCoord(dc)) core.broker = newServerBroker(core) @@ -480,6 +481,7 @@ func Test_createCollectionTask_Execute(t *testing.T) { withMeta(meta), withTtSynchronizer(ticker), withGarbageCollector(gc), + withValidProxyManager(), withBroker(broker)) schema := &schemapb.CollectionSchema{