Skip to content

Commit

Permalink
Fix open too many files (#2014)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: Jin Hai <[email protected]>
  • Loading branch information
JinHai-CN authored Oct 11, 2024
1 parent 6fb6a1e commit fc3c067
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/storage/buffer/file_worker/file_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ bool FileWorker::WriteToFile(bool to_spill, const FileWorkerSaveCtx &ctx) {
UnrecoverableError(status.message());
}
file_handle_ = std::move(file_handle);
DeferFn defer_fn([&]() {
file_handle_ = nullptr;
});

bool prepare_success = false;

bool all_save = WriteToFileImpl(to_spill, prepare_success, ctx);
Expand Down Expand Up @@ -79,6 +83,9 @@ bool FileWorker::WriteToFile(bool to_spill, const FileWorkerSaveCtx &ctx) {
UnrecoverableError(status.message());
}
file_handle_ = std::move(file_handle);
DeferFn defer_fn([&]() {
file_handle_ = nullptr;
});

if (to_spill) {
LOG_TRACE(fmt::format("Open spill file: {}, fd: {}", write_path, file_handle_->FileDescriptor()));
Expand Down Expand Up @@ -130,6 +137,7 @@ void FileWorker::ReadFromFile(bool from_spill) {
PersistWriteResult res = persistence_manager_->PutObjCache(read_path);
handler.HandleWriteResult(res);
}
file_handle_ = nullptr;
});
ReadFromFileImpl(file_size);
}
Expand Down

0 comments on commit fc3c067

Please sign in to comment.