Skip to content

RATIS-2183. Detect staled snapshot request. #1173

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

Merged

Conversation

133tosakarin
Copy link
Contributor

move timestamp to LogAppender
@szetszwo
Copy link
Contributor

@133tosakarin , we already have

For new and old snapshotRequest detection, could we reuse them instead of adding a new timestamp?

@133tosakarin
Copy link
Contributor Author

@133tosakarin , we already have

For new and old snapshotRequest detection, could we reuse them instead of adding a new timestamp?

Thanks for the reminder, just use callId.

OneSizeFitsQuorum

This comment was marked as abuse.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@133tosakarin , thanks for the update!

  • Please revert the white space changes in LogAppender and InstallSnapshotRequests.
  • See also the comments inlined.

@@ -71,6 +71,7 @@ class SnapshotInstallationHandler {
private final AtomicBoolean isSnapshotNull = new AtomicBoolean();
private final AtomicLong installedIndex = new AtomicLong(INVALID_LOG_INDEX);
private final AtomicInteger nextChunkIndex = new AtomicInteger(-1);
private final AtomicLong callId = new AtomicLong(-1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call it chunk0CallId and add javadoc:

  /** The callId of the chunk with index 0. */
  private final AtomicLong chunk0CallId = new AtomicLong(-1);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 181 to 182
LOG.warn("{}: Ignoring stale snapshot request {}", getMemberId(),
ServerStringUtils.toInstallSnapshotRequestString(request));
Copy link
Contributor

Choose a reason for hiding this comment

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

Print also the chunk0CallId

      final long chunk0 = chunk0CallId.get();
      if (chunk0 > request.getServerRequest().getCallId()) {
        LOG.warn("{}: Snapshot Request Staled: chunk 0 callId is {} but {}", getMemberId(), chunk0,
            ServerStringUtils.toInstallSnapshotRequestString(request));
        final InstallSnapshotReplyProto reply =  toInstallSnapshotReplyProto(leaderId, getMemberId(),
            currentTerm, snapshotChunkRequest.getRequestIndex(), InstallSnapshotResult.SNAPSHOT_EXPIRED);
        return future.thenApply(dummy -> reply);
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@szetszwo szetszwo changed the title RATIS-2183. Add timestamp field for snapshot request RATIS-2183. Detect staled snapshot request. Oct 31, 2024
Copy link
Contributor

@OneSizeFitsQuorum OneSizeFitsQuorum left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@szetszwo szetszwo merged commit e75a0d5 into apache:master Nov 1, 2024
12 checks passed
@szetszwo
Copy link
Contributor

szetszwo commented Nov 1, 2024

@133tosakarin , thanks for working on this!

@OneSizeFitsQuorum , thanks also for reviewing this!

szetszwo pushed a commit to szetszwo/ratis that referenced this pull request May 23, 2025
szetszwo pushed a commit to szetszwo/ratis that referenced this pull request May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants