(db/snapshot): update LSN logic (#3682)

Signed-off-by: peng.xu <peng.xu@zilliz.com>
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>
This commit is contained in:
XuPeng-SH 2020-09-11 16:07:30 +08:00 committed by shengjun.li
parent 76fa7aa4c6
commit d03a8e4354
4 changed files with 8 additions and 4 deletions

View File

@ -922,6 +922,7 @@ CreatePartitionOperation::DoExecute(StorePtr store) {
CreateCollectionOperation::CreateCollectionOperation(const CreateCollectionContext& context)
: BaseT(OperationContext(), ScopedSnapshotT()), c_context_(context) {
SetContextLsn(c_context_.lsn);
}
Status

View File

@ -49,7 +49,7 @@ class CompoundBaseOperation : public Operations {
// TODO
if (GetContextLsn() == 0) {
SetContextLsn(GetStartedSS()->GetMaxLsn());
} else if (GetContextLsn() <= GetStartedSS()->GetMaxLsn()) {
} else if (GetContextLsn() < GetStartedSS()->GetMaxLsn()) {
return Status(SS_INVALID_CONTEX_ERROR, "Invalid LSN found in operation");
}
return Status::OK();

View File

@ -37,6 +37,9 @@ Operations::Operations(const OperationContext& context, ScopedSnapshotT prev_ss,
uid_(UID++),
status_(SS_OPERATION_PENDING, "Operation Pending"),
type_(type) {
if (prev_ss_ && context_.lsn == 0) {
context_.lsn = prev_ss_->GetMaxLsn();
}
}
std::string

View File

@ -442,7 +442,7 @@ TEST_F(SnapshotTest, PartitionTest2) {
ASSERT_EQ(lsn, ss->GetMaxLsn());
OperationContext context;
context.lsn = lsn;
context.lsn = lsn - 1;
auto cp_op = std::make_shared<CreatePartitionOperation>(context, ss);
std::string partition_name("p1");
PartitionContext p_ctx;
@ -456,7 +456,7 @@ TEST_F(SnapshotTest, PartitionTest2) {
ASSERT_TRUE(partition->HasAssigned());
status = cp_op->Push();
ASSERT_FALSE(status.ok());
ASSERT_FALSE(status.ok()) << status.ToString();
}
TEST_F(SnapshotTest, DropSegmentTest){
@ -696,7 +696,7 @@ TEST_F(SnapshotTest, IndexTest) {
TEST_F(SnapshotTest, OperationTest) {
std::string to_string;
LSN_TYPE lsn;
LSN_TYPE lsn = 0;
Status status;
/* ID_TYPE collection_id; */