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

feat: Add support for dynamicaly reconfig rsync-timeout-ms and throttle-bytes-per-second #2610

Closed
wants to merge 0 commits into from

Conversation

cheniujh
Copy link
Collaborator

@cheniujh cheniujh commented Apr 17, 2024

1 Add config item rsync-timeout-ms
2 Add support for dynamicaly reconfig rsync-timeout-ms and throttle-bytes-per-second
3 Add CI Test for it
fix #2263

@github-actions github-actions bot added the ✏️ Feature New feature or request label Apr 17, 2024
@cheniujh
Copy link
Collaborator Author

cheniujh commented Apr 26, 2024

Testing:

Platform
1 40 CPU Cores, 256GB Memory
2 The maximum tranfer rate between slave and master machine is 2-5 Gib/s
3 Master and slave are deployed on 2 different machines and both machines have identical hardware configurations

Testing Action:
1 Thread1 and Thread2: (Repeat 2000 times)Every 100ms, Send "configSet throttle-bytes-per-second N" (N ranges from 64KB to 5MB) to SlaveNode
2 Thread3 and Thread4:(Repeat 2000 times) Every 100ms, Send "configSet rsync-timeout-ms M"(M ranges from 20ms to 200ms) to SlaveNode
3 Thread 1, 2, 3, 4 are running parallel

Result: No exceptions or errors were found.

Attachments:

1: Network IO Trafiic of Master Machine(Captured in the middle of the test):

image

2: The Log of Slave Node(Captured in the middle of the test):

image

@cheniujh cheniujh requested review from wangshao1 and chejinge April 28, 2024 02:59
@@ -414,6 +414,10 @@ class PikaConf : public pstd::BaseConf {
std::shared_lock l(rwlock_);
return max_rsync_parallel_num_;
}
int64_t rsync_timeout_ms(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

成员函数用驼峰方式命名吧,{跟入参的)加个空格吧,跟其他的保持一致。

int64_t GetWaitTimeoutMs(){
return wait_timout_ms_.load();
}
void ResetThrottleThroughputBytes(size_t new_throughput_bytes_per_s){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

格式问题,{之前的空格,还有函数体部分的缩进。

size_t check_cycle_ = 10;
pstd::Mutex keys_mutex_;
size_t caculate_check_time_us_(int64_t current_time_us, int64_t check_cycle) {
size_t base_aligning_time_us = 1000 * 1000 / check_cycle;
return current_time_us / base_aligning_time_us * base_aligning_time_us;
}
// Rsync timeout value used by WaitObject,defined by user, It's NOT protected by keys_mutex_
std::atomic<int64_t> wait_timout_ms_{1000};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个等待超时的变量我理解定义在throttle里不太好。不行你直接在调用的地方实时获取pika_conf里的值。

@@ -360,6 +360,7 @@ Status RsyncClient::PullRemoteMeta(std::string* snapshot_uuid, std::set<std::str

if (resp.get() == nullptr || resp->code() != RsyncService::kOk) {
s = Status::IOError("kRsyncMeta request failed! db is not exist or doing bgsave");
LOG(INFO) << s.ToString() << ", retries:" << retries;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日志级别调整下吧。

src/throttle.cc Outdated
@@ -19,12 +19,12 @@ Throttle::Throttle(size_t throttle_throughput_bytes, size_t check_cycle)
Throttle::~Throttle() {}

size_t Throttle::ThrottledByThroughput(size_t bytes) {
std::unique_lock lock(keys_mutex_);
size_t available_size = bytes;
size_t now = pstd::NowMicros();
size_t limit_throughput_bytes_s = std::max(static_cast<uint64_t>(throttle_throughput_bytes_),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的FLAGS_raft_minimal_throttle_threshold_mb去掉吧,应该是之前抄braft的代码忘了改。

if(last_rsync_config_updated_time_ms_.load() + 1000 < pstd::NowMilliSeconds()){
//maximum update frequency of rsync config:1 time per sec
{
std::lock_guard guard(keys_mutex_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方用了原子变量,就不需要再用互斥锁了吧?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

主从全量复制一直timeout
4 participants