Skip to content

Commit

Permalink
[SKV-636] fix: log error but not crash if found an imcomplete replica…
Browse files Browse the repository at this point in the history
… path (apache#1428)
  • Loading branch information
acelyc111 authored and 王聃 committed May 4, 2023
1 parent 00dd005 commit 93e7350
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ function(dsn_setup_compiler_flags)
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-strict-aliasing)
add_compile_options(-Wuninitialized)
add_compile_options(-Wno-unused-result)
add_compile_options(-Wno-unused-variable)
add_compile_options(-Wno-deprecated-declarations)
add_compile_options(-Wno-inconsistent-missing-override)
Expand Down
3 changes: 2 additions & 1 deletion src/rdsn/include/dsn/dist/replication/replication_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <dsn/dist/replication/replication_other_types.h>
#include <dsn/dist/replication/replication.codes.h>
#include <dsn/dist/replication/replica_base.h>
#include <dsn/utility/ports.h>
#include <atomic>

namespace dsn {
Expand All @@ -58,7 +59,7 @@ class replica_init_info

public:
replica_init_info() { memset((void *)this, 0, sizeof(*this)); }
error_code load(const std::string &dir);
error_code load(const std::string &dir) WARN_UNUSED_RESULT;
error_code store(const std::string &dir);
std::string to_string();

Expand Down
9 changes: 9 additions & 0 deletions src/rdsn/include/dsn/utility/ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,12 @@ static_assert((CACHELINE_SIZE & (CACHELINE_SIZE - 1)) == 0 &&
#else
#define CACHELINE_ALIGNED
#endif

// Annotate a function indicating the caller must examine the return value.
// Use like:
// int foo() WARN_UNUSED_RESULT;
#if defined(__GNUC__)
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
#define WARN_UNUSED_RESULT
#endif
5 changes: 4 additions & 1 deletion src/rdsn/src/replica/replication_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ error_code write_blob_to_file(const std::string &file, const blob &data)
error_code replica_init_info::load(const std::string &dir)
{
std::string info_path = utils::filesystem::path_combine(dir, kInitInfo);
dassert_f(utils::filesystem::path_exists(info_path), "file({}) not exist", info_path);
ERR_LOG_AND_RETURN_NOT_TRUE(utils::filesystem::path_exists(info_path),
ERR_PATH_NOT_FOUND,
"file({}) not exist",
info_path);
ERR_LOG_AND_RETURN_NOT_OK(
load_json(info_path), "load replica_init_info from {} failed", info_path);
ddebug_f("load replica_init_info from {} succeed: {}", info_path, to_string());
Expand Down

0 comments on commit 93e7350

Please sign in to comment.