-
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
Confusing Behaviour of Single Node Scenario #1162
Comments
This will not happen unless the client initiates the same request multiple times.
I didn't understand, could you show me the code? |
It seems there may be some misunderstanding regarding the state machine and log application. Each time a node restarts, its state machine must reset to an empty(initial) state, and the logs in the Raft log storage are replayed to restore its last state before the restart. When snapshots are enabled, the node loads the snapshot and replays the logs after the snapshot's log index. Please read the JRaft user guide thoroughly, and consider reading RAFT algorithm papers or articles to enhance your understanding of JRaft. |
It's possibly the result of logs replay. I'll check it later and thanks for reply. |
Your question
What's the expected behaviour of single node scenario?
Your scenes
I'm building a distributed system using JRaft and currently I'm trying to start only one instance for testing. The logic is simple as the counter example, a task is emitted somewhere and the state machine consume the task and execute responsive operation. But the fact is after emitting a task, the apply function in state machine is invoked multiple times
which causes repeat consumption. At the same time, the term keeps increasing until the hook onLeaderStart is invoked.
Another problem is, in the apply function, the task data is incorrect and can't be deserialized until the hook onLeaderStart is invoked.
I'm just a begniner of JRaft and not sure if it's a limitation of JRaft or caused by some incorrect coding by me. Thanks in advance for reply.
Your advice
Environment
SOFAJRaft version: 1.3.15
JVM version (e.g.
java -version
): jbr-17OS version (e.g.
uname -a
): Darwin HNWYJ3K2W5 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:51:54 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6000 arm64Maven version: 3.8.6
IDE version: Idea
The text was updated successfully, but these errors were encountered: