Skip to content

Commit

Permalink
Remove slave-read-only config option
Browse files Browse the repository at this point in the history
Set slave-read-only yes as always
  • Loading branch information
whoiami committed Jun 5, 2019
1 parent aa9ddc7 commit 6928699
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 32 deletions.
2 changes: 0 additions & 2 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ slowlog-write-errorlog : no
slowlog-log-slower-than : 10000
# Slowlog-max-len
slowlog-max-len : 128
# slave-read-only(yes/no, 1/0)
slave-read-only : yes
# Pika db sync path
db-sync-path : ./dbsync/
# db sync speed(MB) max is set to 1024MB, min is set to 0, and if below 0 or above 1024, the value will be adjust to 1024
Expand Down
5 changes: 0 additions & 5 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ class PikaConf : public slash::BaseConf {
RWLock l(&rwlock_, true);
table_structs_ = table_structs;
}
void SetSlaveReadOnly(const bool value) {
RWLock l(&rwlock_, true);
TryPushDiffCommands("slave-read-only", value == true ? "yes" : "no");
slave_read_only_ = value;
}
void SetExpireLogsNums(const int value){
RWLock l(&rwlock_, true);
TryPushDiffCommands("expire-logs-nums", std::to_string(value));
Expand Down
24 changes: 1 addition & 23 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,15 +670,13 @@ void InfoCmd::InfoReplication(std::string& info) {
tmp_stream << "master_link_status:" << (((g_pika_server->repl_state() == PIKA_REPL_META_SYNC_DONE)
&& g_pika_server->AllPartitionConnectSuccess()) ? "up" : "down") << "\r\n";
tmp_stream << "slave_priority:" << g_pika_conf->slave_priority() << "\r\n";
tmp_stream << "slave_read_only:" << g_pika_conf->slave_read_only() << "\r\n";
tmp_stream << "repl_state: " << (g_pika_server->repl_state_str()) << "\r\n";
break;
case PIKA_ROLE_MASTER | PIKA_ROLE_SLAVE :
tmp_stream << "master_host:" << g_pika_server->master_ip() << "\r\n";
tmp_stream << "master_port:" << g_pika_server->master_port() << "\r\n";
tmp_stream << "master_link_status:" << (((g_pika_server->repl_state() == PIKA_REPL_META_SYNC_DONE)
&& g_pika_server->AllPartitionConnectSuccess()) ? "up" : "down") << "\r\n";
tmp_stream << "slave_read_only:" << g_pika_conf->slave_read_only() << "\r\n";
tmp_stream << "repl_state: " << (g_pika_server->repl_state_str()) << "\r\n";
case PIKA_ROLE_SINGLE :
case PIKA_ROLE_MASTER :
Expand Down Expand Up @@ -1155,12 +1153,6 @@ void ConfigCmd::ConfigGet(std::string &ret) {
EncodeInt32(&config_body, g_pika_conf->slowlog_max_len());
}

if (slash::stringmatch(pattern.data(), "slave-read-only", 1)) {
elements += 2;
EncodeString(&config_body, "slave-read-only");
EncodeString(&config_body, g_pika_conf->slave_read_only() ? "yes" : "no");
}

if (slash::stringmatch(pattern.data(), "write-binlog", 1)) {
elements += 2;
EncodeString(&config_body, "write-binlog");
Expand Down Expand Up @@ -1247,7 +1239,7 @@ void ConfigCmd::ConfigGet(std::string &ret) {
void ConfigCmd::ConfigSet(std::string& ret) {
std::string set_item = config_args_v_[1];
if (set_item == "*") {
ret = "*22\r\n";
ret = "*21\r\n";
EncodeString(&ret, "timeout");
EncodeString(&ret, "requirepass");
EncodeString(&ret, "masterauth");
Expand All @@ -1262,7 +1254,6 @@ void ConfigCmd::ConfigSet(std::string& ret) {
EncodeString(&ret, "slowlog-write-errorlog");
EncodeString(&ret, "slowlog-log-slower-than");
EncodeString(&ret, "slowlog-max-len");
EncodeString(&ret, "slave-read-only");
EncodeString(&ret, "write-binlog");
EncodeString(&ret, "max-cache-statistic-keys");
EncodeString(&ret, "small-compaction-threshold");
Expand Down Expand Up @@ -1366,19 +1357,6 @@ void ConfigCmd::ConfigSet(std::string& ret) {
g_pika_conf->SetSlowlogMaxLen(ival);
g_pika_server->SlowlogTrim();
ret = "+OK\r\n";
} else if (set_item == "slave-read-only") {
slash::StringToLower(value);
bool is_readonly;
if (value == "1" || value == "yes") {
is_readonly = true;
} else if (value == "0" || value == "no") {
is_readonly = false;
} else {
ret = "-ERR Invalid argument \'" + value + "\' for CONFIG SET 'slave-read-only'\r\n";
return;
}
g_pika_conf->SetSlaveReadOnly(is_readonly);
ret = "+OK\r\n";
} else if (set_item == "max-cache-statistic-keys") {
if (!slash::string2l(value.data(), value.size(), &ival) || ival < 0) {
ret = "-ERR Invalid argument \'" + value + "\' for CONFIG SET 'max-cache-statistic-keys'\r\n";
Expand Down
3 changes: 1 addition & 2 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ int PikaConf::Load()
expire_logs_days_ = 1;
}
GetConfStr("compression", &compression_);
// set slave read only true as default
slave_read_only_ = true;
GetConfBool("slave-read-only", &slave_read_only_);
GetConfInt("slave-priority", &slave_priority_);

//
Expand Down Expand Up @@ -366,7 +366,6 @@ int PikaConf::ConfigRewrite() {
SetConfStr("slowlog-write-errorlog", slowlog_write_errorlog_ ? "yes" : "no");
SetConfInt("slowlog-log-slower-than", slowlog_log_slower_than_);
SetConfInt("slowlog-max-len", slowlog_max_len_);
SetConfStr("slave-read-only", slave_read_only_ ? "yes" : "no");
SetConfStr("compact-cron", compact_cron_);
SetConfStr("compact-interval", compact_interval_);
SetConfStr("network-interface", network_interface_);
Expand Down

0 comments on commit 6928699

Please sign in to comment.