From 8a7e6f815a5697970aa26264c02124e9dfbe3b84 Mon Sep 17 00:00:00 2001 From: shenyushi Date: Mon, 6 Jan 2025 16:47:09 +0800 Subject: [PATCH] Fix status. --- src/storage/buffer/buffer_obj.cpp | 12 +++--------- src/storage/buffer/buffer_obj.cppm | 2 +- src/storage/meta/entry/segment_index_entry.cpp | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/storage/buffer/buffer_obj.cpp b/src/storage/buffer/buffer_obj.cpp index 346daf52d3..18cc779475 100644 --- a/src/storage/buffer/buffer_obj.cpp +++ b/src/storage/buffer/buffer_obj.cpp @@ -67,18 +67,12 @@ void BufferObj::UpdateFileWorkerInfo(UniquePtr new_file_worker) { } } -BufferHandle BufferObj::Load(bool no_mmap) { +BufferHandle BufferObj::Load() { buffer_mgr_->AddRequestCount(); std::unique_lock locker(w_locker_); - if (type_ == BufferType::kMmap && no_mmap) { - if (rc_ > 0) { - String error_message = fmt::format("Buffer {} is mmaped, but has {} references", GetFilename(), rc_); - UnrecoverableError(error_message); - } - type_ = BufferType::kPersistent; - } if (type_ == BufferType::kMmap) { switch (status_) { + case BufferStatus::kUnloaded: case BufferStatus::kLoaded: { break; } @@ -353,7 +347,7 @@ void BufferObj::UnloadInner() { type_ = BufferType::kMmap; } else if (type_ == BufferType::kMmap) { file_worker_->MmapNotNeed(); - status_ = BufferStatus::kFreed; + status_ = BufferStatus::kUnloaded; } else { buffer_mgr_->PushGCQueue(this); status_ = BufferStatus::kUnloaded; diff --git a/src/storage/buffer/buffer_obj.cppm b/src/storage/buffer/buffer_obj.cppm index 8e42304735..95debb4fb0 100644 --- a/src/storage/buffer/buffer_obj.cppm +++ b/src/storage/buffer/buffer_obj.cppm @@ -94,7 +94,7 @@ public: public: // called by ObjectHandle when load first time for that ObjectHandle - BufferHandle Load(bool no_mmap = false); + BufferHandle Load(); // called by BufferMgr in GC process. bool Free(); diff --git a/src/storage/meta/entry/segment_index_entry.cpp b/src/storage/meta/entry/segment_index_entry.cpp index 9f54445f2d..41962c30e4 100644 --- a/src/storage/meta/entry/segment_index_entry.cpp +++ b/src/storage/meta/entry/segment_index_entry.cpp @@ -783,7 +783,7 @@ void SegmentIndexEntry::OptIndex(IndexBase *index_base, const auto [chunk_index_entries, memory_index_entry] = this->GetHnswIndexSnapshot(); for (const auto &chunk_index_entry : chunk_index_entries) { - BufferHandle buffer_handle = chunk_index_entry->GetBufferObj()->Load(true /*no mmap*/); + BufferHandle buffer_handle = chunk_index_entry->GetBufferObj()->Load(); auto *abstract_hnsw = reinterpret_cast(buffer_handle.GetDataMut()); optimize_index(abstract_hnsw); chunk_index_entry->SaveIndexFile();