szetszwo commented on code in PR #1676:
URL: https://github.com/apache/ratis/pull/1676#discussion_r4471569326
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ReadRequestHandler.java:
##########
@@ -81,6 +81,12 @@ RaftGroupMemberId getMemberId() {
}
CompletableFuture<RaftClientReply> staleReadAsync(RaftClientRequest request)
{
+ final long installSnapshot =
server.getSnapshotInstallationHandler().getInProgressInstallSnapshotIndex();
Review Comment:
@amaliujia , currently, we only set inProgressInstallSnapshotIndex for
notifyStateMachineToInstallSnapshot. We should set it also for
checkAndInstallSnapshot. Then, it would work.
```diff
@@ -234,10 +241,19 @@ class SnapshotInstallationHandler {
// update the committed index
// re-load the state machine if this is the last chunk
if (snapshotChunkRequest.getDone()) {
- stateMachine.pause(); // pause the SM right before publishing the
snapshot atomically
- snapshotManager.finalizeSnapshot(request);
- state.reloadStateMachine(lastIncluded);
- chunk0CallId.set(-1);
+ final long i = inProgressInstallSnapshotIndex.getAndUpdate(
+ previous -> previous == INVALID_LOG_INDEX ? lastIncludedIndex
: previous);
+ if (i != INVALID_LOG_INDEX) {
+ throw new IOException("Snapshot (index " + updated + ")
installation is in progress");
+ }
+ try {
+ stateMachine.pause(); // pause the SM right before publishing
the snapshot atomically
+ snapshotManager.finalizeSnapshot(request);
+ state.reloadStateMachine(lastIncluded);
+ chunk0CallId.set(-1);
+ } finally {
+ inProgressInstallSnapshotIndex.set(INVALID_LOG_INDEX);
+ }
}
} finally {
server.updateLastRpcTime(UpdateType.INSTALL_SNAPSHOT_COMPLETE);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]