Skip to content

Commit

Permalink
refactor(backup&restore): add more logs when backup or restore failed
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Nov 29, 2023
1 parent 2ff8c02 commit dcd2be2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/block_service/block_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ block_filesystem *block_service_manager::get_or_create_block_filesystem(const st
if (fs == nullptr) {
LOG_ERROR("acquire block filesystem failed, provider = {}, provider_type = {}",
provider,
std::string(provider_type));
provider_type);
return nullptr;
}

Expand All @@ -93,13 +93,14 @@ block_filesystem *block_service_manager::get_or_create_block_filesystem(const st
utils::split_args(arguments, args);
dsn::error_code err = fs->initialize(args);

const auto provider_desc = fmt::format(
"provider = {}, provider_type = {}, args = {}", provider, provider_type, arguments);
if (dsn::ERR_OK == err) {
LOG_INFO("create block filesystem ok for provider {}", provider);
LOG_INFO("create block filesystem ok for {}", provider_desc);
_fs_map.emplace(provider, std::unique_ptr<block_filesystem>(fs));
} else {
LOG_ERROR("create block file system err {} for provider {}",
std::string(err.to_string()),
provider);
LOG_ERROR(
"create block filesystem failed for {}, error = {}", provider_desc, err.to_string());
delete fs;
fs = nullptr;
}
Expand Down
27 changes: 27 additions & 0 deletions src/meta/meta_backup_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "utils/autoref_ptr.h"
#include "utils/blob.h"
#include "utils/chrono_literals.h"
#include "utils/defer.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/time_utils.h"
Expand Down Expand Up @@ -1245,6 +1246,11 @@ void backup_service::add_backup_policy(dsn::message_ex *msg)
{
configuration_add_backup_policy_request request;
configuration_add_backup_policy_response response;
auto log_on_failed = dsn::defer([&response]() {
if (!response.hint_message.empty()) {
LOG_WARNING(response.hint_message);
}
});

dsn::message_ex *copied_msg = message_ex::copy_message_no_reply(*msg);
::dsn::unmarshall(msg, request);
Expand Down Expand Up @@ -1421,6 +1427,11 @@ void backup_service::query_backup_policy(query_backup_policy_rpc rpc)
{
const configuration_query_backup_policy_request &request = rpc.request();
configuration_query_backup_policy_response &response = rpc.response();
auto log_on_failed = dsn::defer([&response]() {
if (!response.hint_msg.empty()) {
LOG_WARNING(response.hint_msg);
}
});

response.err = ERR_OK;

Expand Down Expand Up @@ -1492,6 +1503,12 @@ void backup_service::modify_backup_policy(configuration_modify_backup_policy_rpc
configuration_modify_backup_policy_response &response = rpc.response();
response.err = ERR_OK;

auto log_on_failed = dsn::defer([&response]() {
if (!response.hint_message.empty()) {
LOG_WARNING(response.hint_message);
}
});

std::shared_ptr<policy_context> context_ptr;
{
zauto_lock _(_lock);
Expand Down Expand Up @@ -1647,6 +1664,11 @@ void backup_service::start_backup_app(start_backup_app_rpc rpc)
{
const start_backup_app_request &request = rpc.request();
start_backup_app_response &response = rpc.response();
auto log_on_failed = dsn::defer([&response]() {
if (!response.hint_message.empty()) {
LOG_WARNING(response.hint_message);
}
});

int32_t app_id = request.app_id;
std::shared_ptr<backup_engine> engine = std::make_shared<backup_engine>(this);
Expand Down Expand Up @@ -1712,6 +1734,11 @@ void backup_service::query_backup_status(query_backup_status_rpc rpc)
{
const query_backup_status_request &request = rpc.request();
query_backup_status_response &response = rpc.response();
auto log_on_failed = dsn::defer([&response]() {
if (!response.hint_message.empty()) {
LOG_WARNING(response.hint_message);
}
});

int32_t app_id = request.app_id;
{
Expand Down

0 comments on commit dcd2be2

Please sign in to comment.