@@ -882,9 +882,7 @@ private ReplayLocateDecision resolveInitReplayStartDecision(
882882 case AT_END :
883883 final long resolvedReplayStartSearchIndex =
884884 replayTarget .getStatus () == ReplayLocateStatus .AT_END
885- ? Math .min (
886- nextSearchIndexAfter (replayTarget .getStartSearchIndex ()),
887- fallbackTailSearchIndex )
885+ ? Math .min (replayTarget .getStartSearchIndex (), fallbackTailSearchIndex )
888886 : replayTarget .getStartSearchIndex ();
889887 return new ReplayLocateDecision (
890888 replayTarget .getStatus (),
@@ -2037,6 +2035,7 @@ private void advanceWalReplayCursorIfPresent(final IndexedConsensusRequest reque
20372035 if (!hasLocalSearchIndex (request )) {
20382036 return ;
20392037 }
2038+
20402039 final long actualSearchIndex = request .getSearchIndex ();
20412040 final long expectedSearchIndex = nextExpectedSearchIndex .get ();
20422041 if (actualSearchIndex > expectedSearchIndex ) {
@@ -3073,28 +3072,15 @@ public void cleanUp() {
30733072 * old files have been reclaimed, the earliest available position may be later than 0.
30743073 */
30753074 public void seekToBeginning () {
3076- final RegionProgress beginningProgress = new RegionProgress (Collections .emptyMap ());
3077- if (consensusReqReader instanceof WALNode ) {
3078- // The first retained WAL index can be greater than one after older files are reclaimed.
3079- seekToRegionProgress (beginningProgress );
3080- } else {
3081- seekToResolvedPosition (FIRST_CONSENSUS_SEARCH_INDEX , beginningProgress , "beginning" );
3082- }
3075+ seekToResolvedPosition (0L , new RegionProgress (Collections .emptyMap ()), "beginning" );
30833076 }
30843077
30853078 /**
30863079 * Seeks to the current WAL write position. After this, only newly written data will be consumed.
30873080 */
30883081 public void seekToEnd () {
3089- final RegionProgress tailProgress = computeTailRegionProgress ();
30903082 seekToResolvedPosition (
3091- nextSearchIndexAfter (consensusReqReader .getCurrentSearchIndex ()), tailProgress , "end" );
3092- }
3093-
3094- private static long nextSearchIndexAfter (final long searchIndex ) {
3095- return searchIndex == Long .MAX_VALUE
3096- ? Long .MAX_VALUE
3097- : Math .max (FIRST_CONSENSUS_SEARCH_INDEX , searchIndex + 1L );
3083+ consensusReqReader .getCurrentSearchIndex (), computeTailRegionProgress (), "end" );
30983084 }
30993085
31003086 public void seekToRegionProgress (final RegionProgress regionProgress ) {
@@ -3122,9 +3108,7 @@ public void seekToRegionProgress(final RegionProgress regionProgress) {
31223108 replayTarget .getStatus (),
31233109 replayTarget .getStartSearchIndex ());
31243110 seekToResolvedPosition (
3125- replayTarget .getStatus () == ReplayLocateStatus .AT_END
3126- ? nextSearchIndexAfter (replayTarget .getStartSearchIndex ())
3127- : replayTarget .getStartSearchIndex (),
3111+ replayTarget .getStartSearchIndex (),
31283112 replayTarget .getRecoveryRegionProgress (),
31293113 "regionProgress" );
31303114 return ;
@@ -3165,9 +3149,7 @@ public void seekAfterRegionProgress(final RegionProgress regionProgress) {
31653149 replayTarget .getStatus (),
31663150 replayTarget .getStartSearchIndex ());
31673151 seekToResolvedPosition (
3168- replayTarget .getStatus () == ReplayLocateStatus .AT_END
3169- ? nextSearchIndexAfter (replayTarget .getStartSearchIndex ())
3170- : replayTarget .getStartSearchIndex (),
3152+ replayTarget .getStartSearchIndex (),
31713153 replayTarget .getRecoveryRegionProgress (),
31723154 "regionProgressAfter" );
31733155 return ;
0 commit comments