Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:Revise the value check for max-rsync-parallel-num to prevent a core dump when it is set to a value greater than 4 #2595

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ default-slot-num : 1024

# Rsync Rate limiting configuration 200MB/s
throttle-bytes-per-second : 207200000

# The valid range for max-rsync-parallel-num is [1, 4].
# If an invalid value is provided, max-rsync-parallel-num will automatically be reset to 4.
max-rsync-parallel-num : 4

# The synchronization mode of Pika primary/secondary replication is determined by ReplicationID. ReplicationID in one replication_cluster are the same
Expand Down
2 changes: 1 addition & 1 deletion include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ class PikaConf : public pstd::BaseConf {

// Rsync Rate limiting configuration
int throttle_bytes_per_second_ = 207200000;
int max_rsync_parallel_num_ = 4;
int max_rsync_parallel_num_ = kMaxRsyncParallelNum;
};

#endif
2 changes: 1 addition & 1 deletion src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,7 @@ void ConfigCmd::ConfigSet(std::shared_ptr<DB> db) {
g_pika_conf->SetThrottleBytesPerSecond(static_cast<int>(ival));
res_.AppendStringRaw("+OK\r\n");
} else if (set_item == "max-rsync-parallel-num") {
if ((pstd::string2int(value.data(), value.size(), &ival) == 0) || ival > kMaxRsyncParallelNum) {
if ((pstd::string2int(value.data(), value.size(), &ival) == 0) || ival > kMaxRsyncParallelNum || ival <= 0) {
res_.AppendStringRaw( "-ERR Invalid argument \'" + value + "\' for CONFIG SET 'max-rsync-parallel-num'\r\n");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ int PikaConf::Load() {
}

GetConfInt("max-rsync-parallel-num", &max_rsync_parallel_num_);
if (max_rsync_parallel_num_ <= 0) {
max_rsync_parallel_num_ = 4;
if (max_rsync_parallel_num_ <= 0 || max_rsync_parallel_num_ > kMaxRsyncParallelNum) {
max_rsync_parallel_num_ = kMaxRsyncParallelNum;
}

return ret;
Expand Down
Loading