mirror of https://github.com/milvus-io/milvus.git
Fix delete records timestamp may be reordered (#27941)
Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/27983/head
parent
4a33391b8f
commit
f212158d61
|
@ -17,6 +17,7 @@
|
|||
#include <thread>
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
#include "common/Consts.h"
|
||||
#include "common/EasyAssert.h"
|
||||
|
@ -236,19 +237,24 @@ SegmentGrowingImpl::Delete(int64_t reserved_begin,
|
|||
ParsePksFromIDs(pks, field_meta.get_data_type(), *ids);
|
||||
|
||||
// filter out the deletions that the primary key not exists
|
||||
auto end = std::remove_if(pks.begin(), pks.end(), [&](const PkType& pk) {
|
||||
return !insert_record_.contain(pk);
|
||||
});
|
||||
size = end - pks.begin();
|
||||
std::vector<std::tuple<Timestamp, PkType>> ordering(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ordering[i] = std::make_tuple(timestamps_raw[i], pks[i]);
|
||||
}
|
||||
auto end =
|
||||
std::remove_if(ordering.begin(),
|
||||
ordering.end(),
|
||||
[&](const std::tuple<Timestamp, PkType>& record) {
|
||||
return !insert_record_.contain(std::get<1>(record));
|
||||
});
|
||||
size = end - ordering.begin();
|
||||
ordering.resize(size);
|
||||
if (size == 0) {
|
||||
return SegcoreError::success();
|
||||
}
|
||||
|
||||
// step 1: sort timestamp
|
||||
std::vector<std::tuple<Timestamp, PkType>> ordering(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ordering[i] = std::make_tuple(timestamps_raw[i], pks[i]);
|
||||
}
|
||||
|
||||
std::sort(ordering.begin(), ordering.end());
|
||||
std::vector<PkType> sort_pks(size);
|
||||
std::vector<Timestamp> sort_timestamps(size);
|
||||
|
|
|
@ -1147,19 +1147,23 @@ SegmentSealedImpl::Delete(int64_t reserved_offset, // deprecated
|
|||
ParsePksFromIDs(pks, field_meta.get_data_type(), *ids);
|
||||
|
||||
// filter out the deletions that the primary key not exists
|
||||
auto end = std::remove_if(pks.begin(), pks.end(), [&](const PkType& pk) {
|
||||
return !insert_record_.contain(pk);
|
||||
});
|
||||
size = end - pks.begin();
|
||||
std::vector<std::tuple<Timestamp, PkType>> ordering(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ordering[i] = std::make_tuple(timestamps_raw[i], pks[i]);
|
||||
}
|
||||
auto end =
|
||||
std::remove_if(ordering.begin(),
|
||||
ordering.end(),
|
||||
[&](const std::tuple<Timestamp, PkType>& record) {
|
||||
return !insert_record_.contain(std::get<1>(record));
|
||||
});
|
||||
size = end - ordering.begin();
|
||||
ordering.resize(size);
|
||||
if (size == 0) {
|
||||
return SegcoreError::success();
|
||||
}
|
||||
|
||||
// step 1: sort timestamp
|
||||
std::vector<std::tuple<Timestamp, PkType>> ordering(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ordering[i] = std::make_tuple(timestamps_raw[i], pks[i]);
|
||||
}
|
||||
std::sort(ordering.begin(), ordering.end());
|
||||
std::vector<PkType> sort_pks(size);
|
||||
std::vector<Timestamp> sort_timestamps(size);
|
||||
|
|
Loading…
Reference in New Issue