troubleshoot deadlock
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-12-23 12:50:33 -06:00
parent ac3e7eef61
commit 2a80d4053c

View File

@ -137,17 +137,21 @@ auto file_manager::create(const std::string &api_path, api_meta_map &meta,
auto file_manager::evict_file(const std::string &api_path) -> bool {
REPERTORY_USES_FUNCTION_NAME();
fmt::println("try evict|{}", api_path);
if (provider_.is_read_only()) {
return false;
}
recur_mutex_lock open_lock(open_file_mtx_);
unique_recur_mutex_lock open_lock(open_file_mtx_);
fmt::println("try evict locked|{}", api_path);
if (is_processing(api_path)) {
fmt::println("proccessing|{}", api_path);
return false;
}
if (get_open_file_count(api_path) != 0U) {
fmt::println("open count|{}", api_path);
return false;
}
@ -174,7 +178,14 @@ auto file_manager::evict_file(const std::string &api_path) -> bool {
return false;
}
std::shared_ptr<i_closeable_open_file> closeable_file;
if (open_file_lookup_.contains(api_path)) {
closeable_file = open_file_lookup_.at(api_path);
}
open_file_lookup_.erase(api_path);
open_lock.unlock();
closeable_file.reset();
auto file = utils::file::file{source_path};
auto file_size = file.size().value_or(0U);
@ -372,10 +383,11 @@ auto file_manager::open(const std::string &api_path, bool directory,
return open(api_path, directory, ofd, handle, file, nullptr);
}
auto file_manager::open(
const std::string &api_path, bool directory, const open_file_data &ofd,
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
auto file_manager::open(const std::string &api_path, bool directory,
const open_file_data &ofd, std::uint64_t &handle,
std::shared_ptr<i_open_file> &file,
std::shared_ptr<i_closeable_open_file> closeable_file)
-> api_error {
REPERTORY_USES_FUNCTION_NAME();
const auto create_and_add_handle =
@ -427,7 +439,7 @@ auto file_manager::open(
auto ring_size{ring_buffer_file_size / chunk_size};
const auto get_download_type = [&](download_type type) -> download_type {
if (fsi.size == 0U) {
if (directory || fsi.size == 0U) {
return download_type::fallback;
}
@ -465,8 +477,10 @@ auto file_manager::open(
};
auto type = get_download_type(config_.get_preferred_download_type());
event_system::instance().raise<download_type_selected>(
fsi.api_path, fsi.source_path, type);
if (not directory) {
event_system::instance().raise<download_type_selected>(
fsi.api_path, fsi.source_path, type);
}
switch (type) {
case repertory::download_type::direct: {
@ -568,7 +582,7 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
void file_manager::remove_resume(const std::string &api_path,
const std::string &source_path) {
return remove_resume(api_path, source_path, false);
remove_resume(api_path, source_path, false);
}
void file_manager::remove_resume(const std::string &api_path,
@ -711,8 +725,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
}
auto file_manager::rename_file(const std::string &from_api_path,
const std::string &to_api_path,
bool overwrite) -> api_error {
const std::string &to_api_path, bool overwrite)
-> api_error {
if (not provider_.is_rename_supported()) {
return api_error::not_implemented;
}
@ -931,10 +945,10 @@ void file_manager::swap_renamed_items(std::string from_api_path,
auto file_iter = open_file_lookup_.find(from_api_path);
if (file_iter != open_file_lookup_.end()) {
auto ptr = std::move(open_file_lookup_[from_api_path]);
auto closeable_file = std::move(open_file_lookup_[from_api_path]);
open_file_lookup_.erase(from_api_path);
ptr->set_api_path(to_api_path);
open_file_lookup_[to_api_path] = std::move(ptr);
closeable_file->set_api_path(to_api_path);
open_file_lookup_[to_api_path] = std::move(closeable_file);
}
if (directory) {