Skip to content

Commit

Permalink
TEST: Use different translog dir for a new engine
Browse files Browse the repository at this point in the history
In #testPruneOnlyDeletesAtMostLocalCheckpoint, we create a new engine
but mistakenly use the same translog directory of  the existing engine.
This prevents translog files from cleaning up when closing the engines.

ERROR   0.12s J2 | InternalEngineTests.testPruneOnlyDeletesAtMostLocalCheckpoint <<< FAILURES!
   > Throwable #1: java.io.IOException: could not remove the following files (in the order of attempts):
   >    translog-primary-060/translog-2.tlog:  java.io.IOException: access denied:

This commit makes sure to use a separate directory for each engine in
this tes.
  • Loading branch information
dnhatn committed Mar 27, 2018
1 parent 8d6832c commit d1d3edf
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4474,21 +4474,14 @@ public void testPruneOnlyDeletesAtMostLocalCheckpoint() throws Exception {
final AtomicLong clock = new AtomicLong(0);
threadPool = spy(threadPool);
when(threadPool.relativeTimeInMillis()).thenAnswer(invocation -> clock.get());
final EngineConfig config = engine.config();
final long gcInterval = randomIntBetween(0, 10);
final IndexSettings indexSettings = engine.config().getIndexSettings();
final IndexMetaData indexMetaData = IndexMetaData.builder(indexSettings.getIndexMetaData())
.settings(Settings.builder().put(indexSettings.getSettings())
.put(IndexSettings.INDEX_GC_DELETES_SETTING.getKey(), TimeValue.timeValueMillis(gcInterval).getStringRep())).build();
indexSettings.updateIndexMetaData(indexMetaData);

try (Store store = createStore();
InternalEngine engine = createEngine(new EngineConfig(config.getShardId(), config.getAllocationId(), threadPool,
indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
config.getTranslogConfig(), config.getFlushMergesAfter(), config.getExternalRefreshListener(), Collections.emptyList(),
config.getIndexSort(), config.getTranslogRecoveryRunner(), config.getCircuitBreakerService(),
config.getGlobalCheckpointSupplier()))) {
InternalEngine engine = createEngine(store, createTempDir())) {
engine.config().setEnableGcDeletes(false);
for (int i = 0, docs = scaledRandomIntBetween(0, 10); i < docs; i++) {
index(engine, i);
Expand Down

0 comments on commit d1d3edf

Please sign in to comment.