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 <xuan.yang@zilliz.com>
This commit is contained in:
XuanYang-cn 2022-01-28 20:49:41 +08:00 committed by GitHub
parent 4b83bbf8e7
commit eef295465a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)