Fix 16961, make creating dml stream idempotent (#17302)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/17304/head
Jiquan Long 2022-05-31 22:58:02 +08:00 committed by GitHub
parent d920e5c915
commit 72f454e054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -329,7 +329,17 @@ func (mgr *singleTypeChannelsMgr) getVChannels(collectionID UniqueID) ([]vChan,
return nil, err
}
func (mgr *singleTypeChannelsMgr) streamExist(collectionID UniqueID) bool {
stream, err := mgr.getStream(collectionID)
return err == nil && stream != nil
}
func (mgr *singleTypeChannelsMgr) createMsgStream(collectionID UniqueID) error {
if mgr.streamExist(collectionID) {
log.Info("stream already exist, no need to re-create", zap.Int64("collection_id", collectionID))
return nil
}
channels, err := mgr.getChannelsFunc(collectionID)
if err != nil {
log.Warn("failed to create message stream",

View File

@ -74,6 +74,10 @@ func TestChannelsMgrImpl_createDMLMsgStream(t *testing.T) {
err = mgr.createDMLMsgStream(collID)
assert.Equal(t, nil, err)
// re-create message stream.
err = mgr.createDMLMsgStream(collID)
assert.Equal(t, nil, err)
_, err = mgr.getChannels(collID)
assert.Equal(t, nil, err)
_, err = mgr.getVChannels(collID)