[
https://issues.apache.org/jira/browse/RATIS-2056?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Attila Doroszlai updated RATIS-2056:
------------------------------------
Summary: IllegalStateException: Unexpected gap in segments: binarySearch
(was: IllegalStateExcetpion: Unexpected gap in segments: binarySearch)
> IllegalStateException: Unexpected gap in segments: binarySearch
> ---------------------------------------------------------------
>
> Key: RATIS-2056
> URL: https://issues.apache.org/jira/browse/RATIS-2056
> Project: Ratis
> Issue Type: Bug
> Components: server, snapshot
> Affects Versions: 3.0.1
> Reporter: Song Ziyang
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> java.lang.IllegalStateException: Unexpected gap in segments:
> binarySearch(5066) returns -1, segments=[log-6057_6058, log-6059_6060]
> at
> org.apache.ratis.server.raftlog.segmented.SegmentedRaftLogCache$LogSegmentList.purge(SegmentedRaftLogCache.java:373)
> at
> org.apache.ratis.server.raftlog.segmented.SegmentedRaftLogCache.purge(SegmentedRaftLogCache.java:614)
> at
> org.apache.ratis.server.raftlog.segmented.SegmentedRaftLog.purgeImpl(SegmentedRaftLog.java:379)
> at org.apache.ratis.server.raftlog.RaftLogBase.purge(RaftLogBase.java:332)
> at
> org.apache.ratis.server.impl.StateMachineUpdater.takeSnapshot(StateMachineUpdater.java:313)
> at
> org.apache.ratis.server.impl.StateMachineUpdater.checkAndTakeSnapshot(StateMachineUpdater.java:275)
> at
> org.apache.ratis.server.impl.StateMachineUpdater.run(StateMachineUpdater.java:192)
> at java.base/java.lang.Thread.run(Thread.java:834)
>
> # This server was recently added to the group, with a snapshot (index=6056)
> installed from the leader.
> # It then applied some new logs and formed log segments log-6057_6058,
> log-6059_6060.
> # Then the server took a new snapshot with index = 6065.
> # When the server tried to purge logs, its suggest purge index was set to
> 5066 (6066 - 1000, 1000 is the preserved logs set by
> server.log.purge.preservation.log.num)
> # The IllegalStateException occurred.
>
> I think purgeIndex is not updated after installing a snapshot from leader.
> [https://github.com/apache/ratis/blob/8638a2ffa802de576aae546c22160da3d9339a8f/ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java#L336-L339]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)