Skip to content

Commit

Permalink
Fix partition's gc (#27816)
Browse files Browse the repository at this point in the history
Signed-off-by: longjiquan <[email protected]>
  • Loading branch information
longjiquan authored Oct 20, 2023
1 parent 9b0ecbd commit babf4e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions internal/metastore/kv/rootcoord/kv_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 16 additions & 4 deletions internal/metastore/kv/rootcoord/kv_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,29 @@ 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}

err := kc.DropPartition(ctx, 0, 100, 101, 0)
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()

Expand Down

0 comments on commit babf4e3

Please sign in to comment.