sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.52k stars 1.12k forks source link

fix: make chaosSplittingCheckData robust #1110

Closed killme2008 closed 2 weeks ago

killme2008 commented 2 weeks ago

Motivation & Modification

As seen in CI https://github.com/sofastack/sofa-jraft/actions/runs/9543270248/job/26299583757

It failed at:

chaosSplittingTest(com.alipay.sofa.jraft.rhea.chaos.ChaosMemoryLeaderReadTest)  Time elapsed: 2.438 sec  <<< ERROR!
java.util.concurrent.ExecutionException: com.alipay.sofa.jraft.rhea.errors.InvalidRegionVersionException: Invalid region version error (region split or merge happened).
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928)
    at com.alipay.sofa.jraft.rhea.client.FutureHelper.get(FutureHelper.java:46)
    at com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore.bGet(DefaultRheaKVStore.java:385)
    at com.alipay.sofa.jraft.rhea.chaos.AbstractChaosTest.chaosSplittingCheckData(AbstractChaosTest.java:237)
    at com.alipay.sofa.jraft.rhea.chaos.AbstractChaosTest.chaosSplittingTest(AbstractChaosTest.java:227)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)

Looks like it's an expected error. So just assert the error message when raising exceptions in chaosSplittingCheckData.

Result:

Fixes #.

If there is no issue then describe the changes introduced by this PR.

Summary by CodeRabbit

coderabbitai[bot] commented 2 weeks ago

[!WARNING]

Rate limit exceeded

@killme2008 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 21 seconds before requesting another review.

How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
Commits Files that changed from the base of the PR and between 3ed6dcc6230d4643cc64e460133a791143fbce62 and 2245e2bf4ad0c5d7f5879034f431578836971baa.

Walkthrough

The NodeTest.java file has been updated to include enhanced exception handling in the testChangePeersChaosApplyTasks method. This enhancement involves the addition of a try-catch block around the future.get() calls, enforcing a timeout of 20 seconds and providing appropriate handling for TimeoutException. The restructuring aims to ensure robustness and reliability in handling futures and timeouts during peer change operations.

Changes

File Summary
jraft-core/src/test/.../NodeTest.java Enhanced testChangePeersChaosApplyTasks with try-catch handling around future.get() calls and restructured loop for robust timeout and TimeoutException handling.

Poem

Amidst the code, in tests so bright, A timeout shield, we set alight. 🌟 With futures called and errors tamed, Stability and order claimed. πŸ•°οΈπŸ”’ In the chaos peers once knew, Now smoother paths, we pursued. πŸš€πŸ‡


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
killme2008 commented 2 weeks ago

A fatal error when testing LogitLogStorage:

>>>>>>>>>>>>>>> Start test method: testInstallLargeSnapshot
Start ensureSame, waitTimes=-1
End ensureSame, waitTimes=-1
Node<10.1.0.100:5004> saved snapshot into /tmp/jraft_test_789104793204/10.1.0.100_5004/snapshot/temp/data
Node<10.1.0.100:5004> saved snapshot into /tmp/jraft_test_789104793204/10.1.0.100_5004/snapshot/temp/data
Node<10.1.0.100:5006> loaded snapshot from /tmp/jraft_test_789104793204/10.1.0.100_5006/snapshot/snapshot_2001/data
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007effd98391ca, pid=20721, tid=0x00007eff3d7ff640
#
# JRE version: OpenJDK Runtime Environment (Zulu 8.78.0.19-CA-linux64) (8.0_412-b08) (build 1.8.0_412-b08)
# Java VM: OpenJDK 64-Bit Server VM (25.412-b08 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V  [libjvm.so+0x8391ca]3,0001,Start ensureSame\u002C waitTimes=-1\n
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/runner/work/sofa-jraft/sofa-jraft/jraft-extension/java-log-storage-impl/hs_err_pid20721.log
End ensureSame, waitTimes=-1
#
# If you would like to submit a bug report, please visit:
#   http://www.azul.com/support/
#
Aborted (core dumped)