-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a linearizable query commit index bug
This commit fixes a rare bug that can occur during membership changes. The fix is validated in the new test case added to LinearizableQueryTest.java. When a membership change is appended to the leader but not yet committed, if the current commit index is X and the last log index is Y where Y > X, when a linearizable query is executed, Y is passed to StateMachine.runOperation() instead of X. This does not violate any consistency property since the query is executed on the latest commit state of the StateMachine, however the incorrect commit index passed to StateMachine might be used for secondary purposes, such as logging, etc. Secondarily, this commit fixes another small bug where a leader Raft node does not gracefully shutdown its components automatically which required a RaftNode#terminate() call after the membership change is committed.
- Loading branch information
Showing
13 changed files
with
275 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
microraft/src/main/java/io/microraft/impl/statemachine/InternalCommitAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2023, MicroRaft. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.microraft.impl.statemachine; | ||
|
||
// mainly used for testing | ||
public interface InternalCommitAware { | ||
|
||
default void onInternalCommit(long commitIndex) { | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
microraft/src/main/java/io/microraft/model/persistence/RaftEndpointPersistentState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
microraft/src/main/java/io/microraft/model/persistence/RaftTermPersistentState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
microraft/src/main/java/io/microraft/persistence/RaftStoreSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.