mirror of https://github.com/milvus-io/milvus.git
fix: #33038 pr: #33040 --------- Signed-off-by: longjiquan <jiquan.long@zilliz.com>pull/33119/head
parent
bfd88670ef
commit
0abc0d05a4
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
@ -94,6 +95,12 @@ func batchMultiSaveAndRemoveWithPrefix(snapshot kv.SnapShotKV, maxTxnNum int, sa
|
|||
return err
|
||||
}
|
||||
|
||||
// avoid a case that the former key is the prefix of the later key.
|
||||
// for example, `root-coord/fields/collection_id/1` is the prefix of `root-coord/fields/collection_id/100`.
|
||||
sort.Slice(removals, func(i, j int) bool {
|
||||
return removals[i] > removals[j]
|
||||
})
|
||||
|
||||
removeFn := func(partialKeys []string) error {
|
||||
return snapshot.MultiSaveAndRemoveWithPrefix(nil, partialKeys, ts)
|
||||
}
|
||||
|
|
|
@ -521,14 +521,17 @@ func (ss *SuffixSnapshot) MultiSaveAndRemoveWithPrefix(saves map[string]string,
|
|||
|
||||
// load each removal, change execution to adding tombstones
|
||||
for _, removal := range removals {
|
||||
keys, _, err := ss.MetaKv.LoadWithPrefix(removal)
|
||||
keys, values, err := ss.MetaKv.LoadWithPrefix(removal)
|
||||
if err != nil {
|
||||
log.Warn("SuffixSnapshot MetaKv LoadwithPrefix failed", zap.String("key", removal), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
// add tombstone to original key and add ts entry
|
||||
for _, key := range keys {
|
||||
for idx, key := range keys {
|
||||
if IsTombstone(values[idx]) {
|
||||
continue
|
||||
}
|
||||
key = ss.hideRootPrefix(key)
|
||||
execute[key] = string(SuffixSnapshotTombstone)
|
||||
execute[ss.composeTSKey(key, ts)] = string(SuffixSnapshotTombstone)
|
||||
|
|
Loading…
Reference in New Issue