Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix replay bug #2141

Merged
merged 9 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/storage/buffer/buffer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ BufferObj *BufferManager::GetBufferObject(UniquePtr<FileWorker> file_worker, boo
if (auto iter1 = buffer_map_.find(file_path); iter1 != buffer_map_.end()) {
BufferObj *buffer_obj = iter1->second.get();
if (restart) {
buffer_obj->SetFileWorker(std::move(file_worker));
buffer_obj->UpdateFileWorkerInfo(std::move(file_worker));
}
return buffer_obj;
}
Expand Down
18 changes: 16 additions & 2 deletions src/storage/buffer/buffer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

module;

#include <cassert>
import stl;
import file_worker;
import buffer_handle;
Expand All @@ -23,6 +23,7 @@ import logger;
import third_party;
import logger;
import file_worker_type;
import var_file_worker;

module buffer_obj;

Expand All @@ -41,7 +42,20 @@ BufferObj::BufferObj(BufferManager *buffer_mgr, bool is_ephemeral, UniquePtr<Fil

BufferObj::~BufferObj() = default;

void BufferObj::SetFileWorker(UniquePtr<FileWorker> file_worker) { file_worker_ = std::move(file_worker); }
void BufferObj::UpdateFileWorkerInfo(UniquePtr<FileWorker> file_worker) {
switch (file_worker_->Type()) {
case FileWorkerType::kVarFile:{
assert(file_worker->Type() == FileWorkerType::kVarFile);
auto *var_file_worker = static_cast<VarFileWorker *>(file_worker_.get());
auto *new_var_file_worker = static_cast<VarFileWorker *>(var_file_worker);
var_file_worker->SetBufferSize(new_var_file_worker->GetBufferSize());
break;
}
default:{
break;
}
}
}

BufferHandle BufferObj::Load() {
std::unique_lock<std::mutex> locker(w_locker_);
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 @@ -86,7 +86,7 @@ public:
BufferObj(const BufferObj &) = delete;
BufferObj &operator=(const BufferObj &) = delete;

void SetFileWorker(UniquePtr<FileWorker> file_worker);
void UpdateFileWorkerInfo(UniquePtr<FileWorker> file_worker);

public:
// called by ObjectHandle when load first time for that ObjectHandle
Expand Down
4 changes: 4 additions & 0 deletions src/storage/buffer/file_worker/var_file_worker.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public:

SizeT GetMemoryCost() const override;

SizeT GetBufferSize() const { return buffer_size_; }

void SetBufferSize(SizeT buffer_size) { buffer_size_ = buffer_size; }

FileWorkerType Type() const override { return FileWorkerType::kVarFile; }

protected:
Expand Down
Loading