mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 20:09:57 +08:00
Wal lsn issue (#2412)
* set wal lsn after all mem files serialized Signed-off-by: groot <yihua.mo@zilliz.com> * typo Signed-off-by: groot <yihua.mo@zilliz.com> * return status Signed-off-by: groot <yihua.mo@zilliz.com>
This commit is contained in:
parent
4ce3e2c03c
commit
077dfa4092
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -59,6 +59,9 @@ class MemTableFile : public server::CacheConfigHandler {
|
||||
const std::string&
|
||||
GetSegmentId() const;
|
||||
|
||||
meta::SegmentSchema
|
||||
GetSegmentSchema() const;
|
||||
|
||||
protected:
|
||||
void
|
||||
OnCacheInsertDataChanged(bool value) override;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user