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: master-slave sync error #1818

Merged
merged 3 commits into from
Jul 26, 2023

Conversation

wangshao1
Copy link
Collaborator

@wangshao1 wangshao1 commented Jul 26, 2023

修复issue中提到的主从复制时两个问题

Fixes: #1817

@@ -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)) {
Copy link

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. Consider validating the input parameters before using them in the code. Ensure that node.ip() and node.port() contain valid values and handle any potential exceptions or errors that may arise from incorrect values.

  6. 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.

src/pika_rm.cc Show resolved Hide resolved
AlexStocks
AlexStocks previously approved these changes Jul 26, 2023
@AlexStocks AlexStocks merged commit 4e92a53 into OpenAtomFoundation:unstable Jul 26, 2023
7 of 8 checks passed
@@ -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;
Copy link

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:

  1. The added code snippet looks fine and doesn't have any apparent syntax or logic errors.

  2. 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.

  3. 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.

  4. 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.

bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* fix: fix master-slave sync error

* fix by review comments

---------

Co-authored-by: wangshaoyi <[email protected]>
Co-authored-by: Xin.Zh <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* fix: fix master-slave sync error

* fix by review comments

---------

Co-authored-by: wangshaoyi <[email protected]>
Co-authored-by: Xin.Zh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

master-slave sync error
2 participants