Skip to content

Commit

Permalink
Fix status.
Browse files Browse the repository at this point in the history
  • Loading branch information
small-turtle-1 committed Jan 6, 2025
1 parent 8ea1e2a commit 8a7e6f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/storage/buffer/buffer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,12 @@ void BufferObj::UpdateFileWorkerInfo(UniquePtr<FileWorker> new_file_worker) {
}
}

BufferHandle BufferObj::Load(bool no_mmap) {
BufferHandle BufferObj::Load() {
buffer_mgr_->AddRequestCount();
std::unique_lock<std::mutex> 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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/buffer/buffer_obj.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/storage/meta/entry/segment_index_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AbstractHnsw *>(buffer_handle.GetDataMut());
optimize_index(abstract_hnsw);
chunk_index_entry->SaveIndexFile();
Expand Down

0 comments on commit 8a7e6f8

Please sign in to comment.