Commit da2d6227 authored by groot's avatar groot Committed by JinHai-CN
Browse files

Wal lsn issue (#2412)



* set wal lsn after all mem files serialized

Signed-off-by: default avatargroot <yihua.mo@zilliz.com>

* typo

Signed-off-by: default avatargroot <yihua.mo@zilliz.com>

* return status

Signed-off-by: default avatargroot <yihua.mo@zilliz.com>
parent 10ee4d90
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -136,8 +136,10 @@ MemTable::Serialize(uint64_t wal_lsn, bool apply_delete) {
        }
    }

    meta::SegmentsSchema update_files;
    for (auto mem_table_file = mem_table_file_list_.begin(); mem_table_file != mem_table_file_list_.end();) {
        auto status = (*mem_table_file)->Serialize(wal_lsn);
        update_files.push_back((*mem_table_file)->GetSegmentSchema());
        if (!status.ok()) {
            return status;
        }
@@ -150,8 +152,13 @@ MemTable::Serialize(uint64_t wal_lsn, bool apply_delete) {
        }
    }

    // Update flush lsn
    auto status = meta_->UpdateCollectionFlushLSN(collection_id_, wal_lsn);
    // Update meta files and flush lsn
    auto status = meta_->UpdateCollectionFiles(update_files);
    if (!status.ok()) {
        return status;
    }

    status = meta_->UpdateCollectionFlushLSN(collection_id_, wal_lsn);
    if (!status.ok()) {
        std::string err_msg = "Failed to write flush lsn to meta: " + status.ToString();
        LOG_ENGINE_ERROR_ << err_msg;
+5 −2
Original line number Diff line number Diff line
@@ -219,8 +219,6 @@ MemTableFile::Serialize(uint64_t wal_lsn) {
        table_file_schema_.file_type_ = meta::SegmentSchema::RAW;
    }

    status = meta_->UpdateCollectionFile(table_file_schema_);

    LOG_ENGINE_DEBUG_ << "New " << ((table_file_schema_.file_type_ == meta::SegmentSchema::RAW) ? "raw" : "to_index")
                      << " file " << table_file_schema_.file_id_ << " of size " << size << " bytes, lsn = " << wal_lsn;

@@ -242,6 +240,11 @@ MemTableFile::GetSegmentId() const {
    return table_file_schema_.segment_id_;
}

meta::SegmentSchema
MemTableFile::GetSegmentSchema() const {
    return table_file_schema_;
}

void
MemTableFile::OnCacheInsertDataChanged(bool value) {
    options_.insert_cache_immediately_ = value;
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@ class MemTableFile : public server::CacheConfigHandler {
    const std::string&
    GetSegmentId() const;

    meta::SegmentSchema
    GetSegmentSchema() const;

 protected:
    void
    OnCacheInsertDataChanged(bool value) override;
+2 −2
Original line number Diff line number Diff line
@@ -238,10 +238,10 @@ TEST_F(MemManagerTest, MEM_TABLE_TEST) {
    status = mem_table.Add(source_10);
    ASSERT_TRUE(status.ok());

    FIU_ENABLE_FIU("SqliteMetaImpl.UpdateCollectionFile.throw_exception");
    FIU_ENABLE_FIU("SqliteMetaImpl.UpdateCollectionFiles.throw_exception");
    status = mem_table.Serialize(0);
    ASSERT_FALSE(status.ok());
    fiu_disable("SqliteMetaImpl.UpdateCollectionFile.throw_exception");
    fiu_disable("SqliteMetaImpl.UpdateCollectionFiles.throw_exception");
}

TEST_F(MemManagerTest2, SERIAL_INSERT_SEARCH_TEST) {