-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: master-slave sync error #1818
fix: master-slave sync error #1818
Conversation
src/pika_repl_server_conn.cc
Outdated
@@ -344,6 +344,9 @@ void PikaReplServerConn::HandleDBSyncRequest(void* arg) { | |||
|
|||
g_pika_server->TryDBSync(node.ip(), node.port() + kPortShiftRSync, db_name, slot_id, | |||
static_cast<int32_t>(slave_boffset.filenum())); | |||
//Change slavenode's state to kSlaveDbSync so that the binlog will perserved. | |||
//See details in SyncMasterSlot::BinlogCloudPurge. | |||
master_slot->ActivateSlaveDbSync(node.ip(), node.port()); | |||
|
|||
std::string reply_str; | |||
if (!response.SerializeToString(&reply_str) || (conn->WriteResp(reply_str) != 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the provided code patch, here are a few observations and suggestions:
-
It seems that the code is modifying an existing function named
PikaReplServerConn::HandleDBSyncRequest()
. Without the complete context of the code, it's difficult to determine if the changes are appropriate or not. Ensure that the modifications align with the intended behavior and follow the coding guidelines of the project. -
The added code activates slave database synchronization (
ActivateSlaveDbSync()
) for a specific node (node.ip()
,node.port()
). Verify that this change is necessary and that it doesn't introduce any unintended side effects. Consider adding comments or documenting the purpose of this activation to provide clarity to future developers. -
Review whether the naming conventions used in the code are consistent with the project's style guide. Ensure that the variable and function names accurately describe their purpose and follow established conventions to enhance code readability.
-
Verify if the dependencies required for the modified code are correctly handled and resolved. Check if the required headers are included and if all functions and methods are properly defined or declared.
-
Consider validating the input parameters before using them in the code. Ensure that
node.ip()
andnode.port()
contain valid values and handle any potential exceptions or errors that may arise from incorrect values. -
Review error handling and ensure that appropriate error messages and logging mechanisms are in place. This will help with troubleshooting and identifying any issues that may occur during execution.
Remember to review the entire codebase comprehensively, including relevant sections that interact with the modified code, to verify the overall correctness and impact of the changes made.
@@ -344,6 +344,8 @@ void PikaReplServerConn::HandleDBSyncRequest(void* arg) { | |||
|
|||
g_pika_server->TryDBSync(node.ip(), node.port() + kPortShiftRSync, db_name, slot_id, | |||
static_cast<int32_t>(slave_boffset.filenum())); | |||
// Change slave node's state to kSlaveDbSync so that the binlog will perserved. | |||
// See details in SyncMasterSlot::BinlogCloudPurge. | |||
master_slot->ActivateSlaveDbSync(node.ip(), node.port()); | |||
|
|||
std::string reply_str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the provided code patch, here is a brief code review:
-
The added code snippet looks fine and doesn't have any apparent syntax or logic errors.
-
It's good to include comments to explain the purpose of the code. The comment provided explains that changing the slave node's state to
kSlaveDbSync
will preserve the binlog. However, it would be even better if the comment included more details about why preserving the binlog is necessary in this context. -
It's difficult to identify potential bugs or improvements without having access to the complete codebase, as the effectiveness of the changes depends on the overall architecture and requirements.
-
To ensure a more comprehensive code review, it would be helpful to provide additional context or relevant sections of code that interact with the code patch.
Overall, the provided code patch seems reasonable, but without a broader understanding of the codebase and the requirements, it's challenging to provide specific bug risks or improvement suggestions.
* fix: fix master-slave sync error * fix by review comments --------- Co-authored-by: wangshaoyi <[email protected]> Co-authored-by: Xin.Zh <[email protected]>
* fix: fix master-slave sync error * fix by review comments --------- Co-authored-by: wangshaoyi <[email protected]> Co-authored-by: Xin.Zh <[email protected]>
修复issue中提到的主从复制时两个问题
Fixes: #1817