@@ -692,13 +692,19 @@ private void finish() {
692692 closeShards (indexShard );
693693 }
694694
695- public void testThrowbackLocalCheckpointOnReplica () throws IOException , InterruptedException {
695+ public void testThrowBackLocalCheckpointOnReplica () throws IOException , InterruptedException {
696696 final IndexShard indexShard = newStartedShard (false );
697697
698698 // most of the time this is large enough that most of the time there will be at least one gap
699699 final int operations = 1024 - scaledRandomIntBetween (0 , 1024 );
700700 indexOnReplicaWithGaps (indexShard , operations , Math .toIntExact (SequenceNumbersService .NO_OPS_PERFORMED ));
701701
702+ final long globalCheckpointOnReplica =
703+ randomIntBetween (
704+ Math .toIntExact (SequenceNumbersService .NO_OPS_PERFORMED ),
705+ Math .toIntExact (indexShard .getLocalCheckpoint ()));
706+ indexShard .updateGlobalCheckpointOnReplica (globalCheckpointOnReplica );
707+
702708 final int globalCheckpoint =
703709 randomIntBetween (
704710 Math .toIntExact (SequenceNumbersService .NO_OPS_PERFORMED ),
@@ -721,9 +727,9 @@ public void onFailure(Exception e) {
721727 ThreadPool .Names .SAME );
722728
723729 latch .await ();
724- assertThat (indexShard .getLocalCheckpoint (), equalTo (( long ) globalCheckpoint ));
730+ assertThat (indexShard .getLocalCheckpoint (), equalTo (Math . max ( globalCheckpoint , globalCheckpointOnReplica ) ));
725731
726- // ensure that after the local checkpoint throwback and indexing again, the local checkpoint advances
732+ // ensure that after the local checkpoint throw back and indexing again, the local checkpoint advances
727733 final Result result = indexOnReplicaWithGaps (indexShard , operations , Math .toIntExact (indexShard .getLocalCheckpoint ()));
728734 assertThat (indexShard .getLocalCheckpoint (), equalTo ((long ) result .localCheckpoint ));
729735
0 commit comments