Fix partition's gc (#27816)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/27834/head
Jiquan Long 2023-10-20 16:30:09 +08:00 committed by GitHub
parent 9b0ecbdca7
commit babf4e37e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -523,6 +523,11 @@ func dropPartition(collMeta *pb.CollectionInfo, partitionID typeutil.UniqueID) {
func (kc *Catalog) DropPartition(ctx context.Context, dbID int64, collectionID typeutil.UniqueID, partitionID typeutil.UniqueID, ts typeutil.Timestamp) error {
collMeta, err := kc.loadCollection(ctx, dbID, collectionID, ts)
if errors.Is(err, merr.ErrCollectionNotFound) {
// collection's gc happened before partition's.
return nil
}
if err != nil {
return err
}

View File

@ -666,10 +666,9 @@ func TestCatalog_DropPartitionV2(t *testing.T) {
t.Run("failed to load collection", func(t *testing.T) {
ctx := context.Background()
snapshot := kv.NewMockSnapshotKV()
snapshot.LoadFunc = func(key string, ts typeutil.Timestamp) (string, error) {
return "", errors.New("mock")
}
snapshot := mocks.NewSnapShotKV(t)
snapshot.On("Load",
mock.Anything, mock.Anything).Return("not in codec format", nil)
kc := Catalog{Snapshot: snapshot}
@ -677,6 +676,19 @@ func TestCatalog_DropPartitionV2(t *testing.T) {
assert.Error(t, err)
})
t.Run("failed to load collection, no key found", func(t *testing.T) {
ctx := context.Background()
snapshot := mocks.NewSnapShotKV(t)
snapshot.On("Load",
mock.Anything, mock.Anything).Return("", merr.WrapErrIoKeyNotFound("partition"))
kc := Catalog{Snapshot: snapshot}
err := kc.DropPartition(ctx, 0, 100, 101, 0)
assert.NoError(t, err)
})
t.Run("partition version after 210", func(t *testing.T) {
ctx := context.Background()