From eef295465af5ab8fb94f8534c45be223d2d09f91 Mon Sep 17 00:00:00 2001 From: XuanYang-cn Date: Fri, 28 Jan 2022 20:49:41 +0800 Subject: [PATCH] Fix timetick inconsistency in drop collection (#15408) When rootcoord drops a collection, it'll produce a `drop-collection DDL` msg and one last timetick into DML channels of this collection. So that when DataNode receives this msg, DN can release the resources for the specific collection. Before this PR, RootCoord produced these two msgs with an older timestamp, generated before many time-consuming RPCs. Once these RPCs spend more time than timetick producing interval, the timetick of these 2 msgs are older to the channel current timestamp, causing in-consistency in time, thus making msgstream fail to consume the last `drop-collection DDL` msg. This PR generates a new timestamp for `drop-collection DDL` msg and timetick msg after those time-consuming RPCs Fixes: #15406 Signed-off-by: yangxuan --- internal/rootcoord/task.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/rootcoord/task.go b/internal/rootcoord/task.go index dfe1577253..05d6028797 100644 --- a/internal/rootcoord/task.go +++ b/internal/rootcoord/task.go @@ -303,6 +303,17 @@ func (t *DropCollectionReqTask) Execute(ctx context.Context) error { return err } + // drop all indices + if err = t.core.RemoveIndex(ctx, t.Req.CollectionName, ""); err != nil { + return err + } + + // Allocate a new ts to make sure the channel timetick is consistent. + ts, err = t.core.TSOAllocator(1) + if err != nil { + return fmt.Errorf("TSO alloc fail, error = %w", err) + } + // build DdOperation and save it into etcd, when ddmsg send fail, // system can restore ddmsg from etcd and re-send ddReq.Base.Timestamp = ts @@ -311,11 +322,6 @@ func (t *DropCollectionReqTask) Execute(ctx context.Context) error { return fmt.Errorf("encodeDdOperation fail, error = %w", err) } - // drop all indices - if err = t.core.RemoveIndex(ctx, t.Req.CollectionName, ""); err != nil { - return err - } - // get all aliases before meta table updated aliases := t.core.MetaTable.ListAliases(collMeta.ID)