Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
feat: make option empty_write_disable mutable (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
levy5307 authored Feb 9, 2022
1 parent 9843e3c commit 82aadea
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,22 @@ DSN_DEFINE_int32("replication",
5,
"concurrent bulk load downloading replica count");

/**
* Empty write is used for flushing WAL log entry which is submit asynchronously.
* Make sure it can work well if you diable it.
*/
DSN_DEFINE_bool("replication",
empty_write_disabled,
false,
"whether to disable empty write, default is false");
DSN_TAG_VARIABLE(empty_write_disabled, FT_MUTABLE);

replication_options::replication_options()
{
deny_client_on_start = false;
verbose_client_log_on_start = false;
verbose_commit_log_on_start = false;
delay_for_fd_timeout_on_start = false;
empty_write_disabled = false;
duplication_enabled = true;

prepare_timeout_ms_for_secondaries = 1000;
Expand Down Expand Up @@ -182,11 +191,6 @@ void replication_options::initialize()
delay_for_fd_timeout_on_start,
"whether to delay for beacon grace period to make failure "
"detector timeout when starting the server, default is false");
empty_write_disabled =
dsn_config_get_value_bool("replication",
"empty_write_disabled",
empty_write_disabled,
"whether to disable empty write, default is false");

duplication_enabled = dsn_config_get_value_bool(
"replication", "duplication_enabled", duplication_enabled, "is duplication enabled");
Expand Down
1 change: 0 additions & 1 deletion src/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class replication_options
bool verbose_client_log_on_start;
bool verbose_commit_log_on_start;
bool delay_for_fd_timeout_on_start;
bool empty_write_disabled;
bool duplication_enabled;

int32_t prepare_timeout_ms_for_secondaries;
Expand Down
7 changes: 4 additions & 3 deletions src/replica/replica_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

namespace dsn {
namespace replication {
DSN_DECLARE_bool(empty_write_disabled);

void replica::init_group_check()
{
Expand Down Expand Up @@ -139,7 +140,7 @@ void replica::broadcast_group_check()
}

// send empty prepare when necessary
if (!_options->empty_write_disabled &&
if (!FLAGS_empty_write_disabled &&
dsn_now_ms() >= _primary_states.last_prepare_ts_ms + _options->group_check_interval_ms) {
mutation_ptr mu = new_mutation(invalid_decree);
mu->add_client_request(RPC_REPLICATION_WRITE_EMPTY, nullptr);
Expand Down Expand Up @@ -248,5 +249,5 @@ void replica::inject_error(error_code err)
[this, err]() { handle_local_failure(err); },
get_gpid().thread_hash());
}
}
} // end namepspace
} // namespace replication
} // namespace dsn
3 changes: 2 additions & 1 deletion src/replica/split/replica_split_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace dsn {
namespace replication {
DSN_DECLARE_bool(empty_write_disabled);

replica_split_manager::replica_split_manager(replica *r)
: replica_base(r), _replica(r), _stub(r->get_replica_stub())
Expand Down Expand Up @@ -631,7 +632,7 @@ void replica_split_manager::parent_handle_child_catch_up(
// sync_point is the first decree after parent send write request to child synchronously
// when sync_point commit, parent consider child has all data it should have during async-learn
decree sync_point = _replica->_prepare_list->max_decree() + 1;
if (!_replica->_options->empty_write_disabled) {
if (!FLAGS_empty_write_disabled) {
// empty wirte here to commit sync_point
mutation_ptr mu = _replica->new_mutation(invalid_decree);
mu->add_client_request(RPC_REPLICATION_WRITE_EMPTY, nullptr);
Expand Down

0 comments on commit 82aadea

Please sign in to comment.