Skip to content

Commit

Permalink
fix: log error but not crash if found an imcomplete replica path (#1428)
Browse files Browse the repository at this point in the history
#1383

The replica instance path will be removed to trash path, a.k.a
`<table_id>.<pid>.<timestamp>.err`, but it may not complete when
a replica server crash, then the path is left but some files
(e.g. `.init-info`) in the path have been moved. When restart
the server after that, server will crash because of a check on
existence of the files, which is not necessary, the server is
able to trash the corrupt path and start normally, the missing
replica can be recovered from other servers automatically.

This patch removes the check.
  • Loading branch information
acelyc111 authored Apr 4, 2023
1 parent f630ce1 commit 0199ede
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/replica/replication_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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);
CHECK(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);
LOG_INFO("load replica_init_info from {} succeed: {}", info_path, to_string());
Expand Down
3 changes: 2 additions & 1 deletion src/replica/replication_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "replica/replica_base.h"
#include "replica_admin_types.h"
#include "utils/error_code.h"
#include "utils/ports.h"

namespace dsn {
class app_info;
Expand Down Expand Up @@ -69,7 +70,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

0 comments on commit 0199ede

Please sign in to comment.