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:delete consensus level #1844

Merged
merged 7 commits into from
Aug 1, 2023
Merged

fix:delete consensus level #1844

merged 7 commits into from
Aug 1, 2023

Conversation

chejinge
Copy link
Collaborator

No description provided.

if (g_pika_conf->consensus_level() != 0) {
LogOffset last_log = master_slot->ConsensusLastIndex();
tmp_stream << db_name << " consensus last_log=" << last_log.ToString() << "\r\n";
}
}
}

Copy link

Choose a reason for hiding this comment

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

In the given code patch, the following changes were made:

  1. The code block starting at line 1087 and ending at line 1091 was removed. This block checked if the consensus level was not equal to zero and then retrieved the last log index from the master slot using ConsensusLastIndex() function.

Code review observations:

  • It appears that the functionality related to the consensus level and last log retrieval has been removed in this patch.
  • If the removal of this code is intentional and does not affect the desired behavior of the program, then there may not be any bug risks associated with it.

Improvement suggestion:

  • Without more context about the intention behind removing the code, it is difficult to provide specific improvement suggestions. However, it is generally important to carefully review the consequences of removing functionality from a codebase.
  • If the removal of the consensus-related code was intended, considering adding comments or a code comment explaining the rationale behind removing it can be helpful for future reference and collaboration.

Please note that without further details, it is challenging to provide an in-depth code review. Additionally, reviewing an isolated code patch may not provide a complete understanding of the overall codebase and its dependencies.

@chejinge chejinge added the bug label Jul 31, 2023
@chejinge chejinge changed the title delete_consensus_level fix:delete_consensus_level Jul 31, 2023
}
// level is always 0
*resp_ptr = std::move(cmd_ptr->res().message());
resp_num--;
}

// Initial permission status
Copy link

Choose a reason for hiding this comment

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

Code Review:

  1. In the first code block, the lines if (g_pika_conf->consensus_level() != 0 && c_ptr->is_write()) are commented out. It seems like this logic was removed. If it was intentional, then it's fine. Otherwise, if the check is still required, make sure to update the code accordingly.

  2. In the second code block, the lines if (g_pika_conf->consensus_level() != 0 && c_ptr->is_write()) are also commented out. Again, ensure that this change is intentional and aligns with the desired behavior.

  3. In the third code block, the condition g_pika_conf->consensus_level() == 0 is always true, and as a result, the code inside the if-block will always execute. This makes the comment misleading. If the intention is to check a different condition or perform different logic based on the consensus level, make sure to update the code accordingly.

Overall, without knowing the specific context and requirements of your application, it's difficult to provide detailed bug risks and improvement suggestions. However, do review the changes made to the code carefully, ensuring they align with the intended functionality. Also, consider updating comments to accurately reflect the code logic.

@chejinge chejinge changed the title fix:delete_consensus_level fix:delete consensus level Jul 31, 2023
}
// level is always 0
*resp_ptr = std::move(cmd_ptr->res().message());
resp_num--;
}

// Initial permission status
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 some observations and suggestions for improvement:

  1. Removed code: In the first change, lines 77-78 are removed. This removes an empty line, which seems to be a formatting change and does not affect functionality.

  2. Consensus level check: In line 79, there is a check for consensus_level() != 0. It is assumed that this condition determines whether the consensus level is non-zero, implying some form of distributed or replicated system. The subsequent if-block modifies the stage of the command based on this condition. Without more context, it is not possible to determine if this change is correct or introduces a bug.

  3. ExecRedisCmd function: It appears that the function takes a Redis command input, executes it using DoCmd, and stores the result in resp_ptr. The change made in lines 276-281 suggests that now the response is always set to the message obtained from the command execution (cmd_ptr->res().message()), irrespective of the consensus level or command type. This might be intentional, but without further knowledge of the code and requirements, it's difficult to assess whether this change is appropriate.

In summary, besides the removal of an empty line, the main change is in how the response is handled in the ExecRedisCmd function. It sets the response to the message obtained from the command execution, regardless of the consensus level or command type. Depending on your specific use case and requirements, this change may or may not be suitable.

src/pika_client_conn.cc Outdated Show resolved Hide resolved
src/pika_consensus.cc Outdated Show resolved Hide resolved
src/pika_consensus.cc Outdated Show resolved Hide resolved
src/pika_server.cc Show resolved Hide resolved
CMakeLists.txt Outdated
@@ -683,7 +681,6 @@ if (USE_PIKA_TOOLS)
make PREFIX=${STAGED_INSTALL_PREFIX} -j${CPU_CORE} install
)
set(BZ2_LIBRARY ${INSTALL_LIBDIR}/libbz2.a)
endif()

if(${OS_VERSION} MATCHES "CentOS")
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR_64}/librocksdb.a)
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's a brief code review:

  1. The section of code that starts with option(USE_PIKA_TOOLS "compile pika-tools" OFF) is commented out using if (USE_PIKA_TOOLS). It appears to disable the compilation of pika-tools if the option is not enabled. If this is intentional, there is no bug risk in this specific change.

  2. The line set(BZ2_LIBRARY ${INSTALL_LIBDIR}/libbz2.a) is not dependent on the USE_PIKA_TOOLS option, so it should be moved outside the if (USE_PIKA_TOOLS) block to ensure it is always executed when appropriate.

  3. Without further context, it is difficult to identify other potential bug risks or improvement suggestions. A more thorough code review would require understanding the purpose and structure of the entire codebase.

Consider providing additional information or specific areas of concern for a more comprehensive analysis.

CMakeLists.txt Outdated
@@ -683,7 +683,6 @@ if (USE_PIKA_TOOLS)
make PREFIX=${STAGED_INSTALL_PREFIX} -j${CPU_CORE} install
)
set(BZ2_LIBRARY ${INSTALL_LIBDIR}/libbz2.a)
endif()

if(${OS_VERSION} MATCHES "CentOS")
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR_64}/librocksdb.a)
Copy link

Choose a reason for hiding this comment

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

It appears that there are some changes to the code patch. Here are some observations and suggestions based on the provided code:

  1. The @@ -625,7 +625,6 @@ and @@ -655,6 +654,7 @@ lines indicate changes in the code, but the actual code changes themselves are missing. It would be helpful to have the actual modified code snippets to perform a thorough review.

  2. The option(USE_PIKA_TOOLS "compile pika-tools" OFF) line sets an option to compile pika-tools. Ensure that this option is being used appropriately throughout the codebase.

  3. The ExternalProject_Add(hiredis ...) section seems to be related to compiling the hiredis library. Verify that all dependencies required for compiling hiredis are correctly specified and installed.

  4. The ExternalProject_Add(bz2 ...) section seems to be related to compiling the bz2 library. Similarly, verify that all dependencies required for compiling bz2 are properly specified and installed.

  5. Check if the libraries (HIREDIS_LIBRARY, BZ2_LIBRARY, ROCKSDB_LIBRARY) are being used correctly in the subsequent code. Ensure that the paths are accurate and match the actual library locations.

Without the actual modified code, it is difficult to provide a detailed analysis of potential bug risks or improvement suggestions. It is advised to review the modified sections carefully, verify the dependencies, and ensure the correct usage of libraries in the code.

@chejinge chejinge merged commit e4c196f into OpenAtomFoundation:unstable Aug 1, 2023
chejinge added a commit that referenced this pull request Aug 1, 2023
* Optimized code logic (#1834)

* fix:delete consensus level (#1844)

* delete_consensus_level

---------

Co-authored-by: Mixficsol <838844609@qq.com>
Mixficsol added a commit that referenced this pull request Aug 4, 2023
* Optimized code logic (#1834)

* fix:delete consensus level (#1844)

* delete_consensus_level

* Update pika.conf (#1854)

* fix:delete_consensus_level (#1852)

* delete_consensus_level

* fix:shutdown&&slaveof no one too slow (#1859)

* fix_slow_shut_down

* add go integrate test (#1792)

* add go integrate test

* add go integrate test

* add go integrate test

* add go integrate test

* temp test

* temp test

* temp test

* temp test

* temp test

* temp test

* add test

* temp test

* temp test

* add tcl

* add tcl

* reformat code

* add tcl

* reformat code

* add tcl

* reformat code

* add tcl

* fix setxx

* fix setxx

* add tcl

* add tcl

* fix: fix some compile error (#1861)

Co-authored-by: wangshaoyi <wangshaoyi@meituan.com>

* change-version

* feat: add diskrecovery command (#1843)

* Add diskrecovery command

* Add diskrecovery command

---------

Co-authored-by: chejinge <945997690@qq.com>
Co-authored-by: Yuecai Liu <38887641+luky116@users.noreply.github.com>
Co-authored-by: wangshao1 <30471730+wangshao1@users.noreply.github.com>
Co-authored-by: wangshaoyi <wangshaoyi@meituan.com>
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants