Skip to content

Commit

Permalink
Fix order and beef up test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Jun 30, 2017
1 parent 8f74e92 commit 5e9d79f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2065,8 +2065,8 @@ public void acquireReplicaOperationPermit(final long operationPrimaryTerm, final
getLocalCheckpoint(),
globalCheckpoint,
globalCheckpoint);
getEngine().seqNoService().resetLocalCheckpoint(globalCheckpoint);
updateGlobalCheckpointOnReplica(globalCheckpoint);
getEngine().seqNoService().resetLocalCheckpoint(getGlobalCheckpoint());
getEngine().getTranslog().rollGeneration();
});
globalCheckpointUpdated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,19 @@ private void finish() {
closeShards(indexShard);
}

public void testThrowbackLocalCheckpointOnReplica() throws IOException, InterruptedException {
public void testThrowBackLocalCheckpointOnReplica() throws IOException, InterruptedException {
final IndexShard indexShard = newStartedShard(false);

// most of the time this is large enough that most of the time there will be at least one gap
final int operations = 1024 - scaledRandomIntBetween(0, 1024);
indexOnReplicaWithGaps(indexShard, operations, Math.toIntExact(SequenceNumbersService.NO_OPS_PERFORMED));

final long globalCheckpointOnReplica =
randomIntBetween(
Math.toIntExact(SequenceNumbersService.NO_OPS_PERFORMED),
Math.toIntExact(indexShard.getLocalCheckpoint()));
indexShard.updateGlobalCheckpointOnReplica(globalCheckpointOnReplica);

final int globalCheckpoint =
randomIntBetween(
Math.toIntExact(SequenceNumbersService.NO_OPS_PERFORMED),
Expand All @@ -721,9 +727,9 @@ public void onFailure(Exception e) {
ThreadPool.Names.SAME);

latch.await();
assertThat(indexShard.getLocalCheckpoint(), equalTo((long) globalCheckpoint));
assertThat(indexShard.getLocalCheckpoint(), equalTo(Math.max(globalCheckpoint, globalCheckpointOnReplica)));

// ensure that after the local checkpoint throwback and indexing again, the local checkpoint advances
// ensure that after the local checkpoint throw back and indexing again, the local checkpoint advances
final Result result = indexOnReplicaWithGaps(indexShard, operations, Math.toIntExact(indexShard.getLocalCheckpoint()));
assertThat(indexShard.getLocalCheckpoint(), equalTo((long) result.localCheckpoint));

Expand Down

0 comments on commit 5e9d79f

Please sign in to comment.