Skip to content

Commit

Permalink
Fix IndexShardIT#testMaybeFlush (#52247)
Browse files Browse the repository at this point in the history
Since #51905, we use the local checkpoint of the safe commit to 
calculate the number of uncommitted operations of a translog stats. If a
periodic flush triggered by afterWriteOperation completes before we sync
translog, then the last commit is not safe. We also need to sync
translog from Engine instead of the translog so that we can advance the
safe commit.

Relates #51905
Closes #52223
  • Loading branch information
dnhatn authored Feb 12, 2020
1 parent 6b62ec5 commit 6c9bdb8
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ public void testMaybeFlush() throws Exception {
assertFalse(shard.shouldPeriodicallyFlush());
assertThat(shard.flushStats().getPeriodic(), greaterThan(0L));
});
shard.sync();
assertEquals(0, translog.stats().getUncommittedOperations());
translog.sync();
long size = Math.max(translog.stats().getUncommittedSizeInBytes(), Translog.DEFAULT_HEADER_SIZE_IN_BYTES + 1);
logger.info("--> current translog size: [{}] num_ops [{}] generation [{}]",
translog.stats().getUncommittedSizeInBytes(), translog.stats().getUncommittedOperations(), translog.getGeneration());
Expand All @@ -369,6 +369,7 @@ public void testMaybeFlush() throws Exception {
commitStats.getUserData(), flushStats.getPeriodic(), flushStats.getTotal());
assertFalse(shard.shouldPeriodicallyFlush());
});
shard.sync();
assertEquals(0, translog.stats().getUncommittedOperations());
}

Expand Down

0 comments on commit 6c9bdb8

Please sign in to comment.