Close first engine instance before creating second (#1457)

When creating the second instance of an InternalEngine using the same
translog config of the default InternalEngine instance, the second
instance will attempt to delete all the existing translog files. I found
a deterministic test failure when running with the seed
`E3E6AAD95ABD299B`.

As opposed to creating a second engine instance with a different
translog location, just close the first one before creating the second.

Signed-off-by: Andrew Ross <andrross@amazon.com>
This commit is contained in:
Andrew Ross 2021-10-28 03:11:05 -05:00 committed by GitHub
parent 37ac3788a3
commit 12789f89a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 32 deletions

View File

@ -3807,38 +3807,35 @@ public class InternalEngineTests extends EngineTestCase {
} }
TranslogDeletionPolicyFactory translogDeletionPolicyFactory = CustomTranslogDeletionPolicy::new; TranslogDeletionPolicyFactory translogDeletionPolicyFactory = CustomTranslogDeletionPolicy::new;
try (Store store = createStore()) { EngineConfig config = engine.config();
EngineConfig config = engine.config(); EngineConfig configWithCustomTranslogDeletionPolicyFactory = new EngineConfig(
config.getShardId(),
EngineConfig configWithCustomTranslogDeletionPolicyFactory = new EngineConfig( config.getThreadPool(),
config.getShardId(), config.getIndexSettings(),
config.getThreadPool(), config.getWarmer(),
config.getIndexSettings(), config.getStore(),
config.getWarmer(), config.getMergePolicy(),
store, config.getAnalyzer(),
config.getMergePolicy(), config.getSimilarity(),
config.getAnalyzer(), new CodecService(null, logger),
config.getSimilarity(), config.getEventListener(),
new CodecService(null, logger), config.getQueryCache(),
config.getEventListener(), config.getQueryCachingPolicy(),
config.getQueryCache(), config.getTranslogConfig(),
config.getQueryCachingPolicy(), translogDeletionPolicyFactory,
config.getTranslogConfig(), config.getFlushMergesAfter(),
translogDeletionPolicyFactory, config.getExternalRefreshListener(),
config.getFlushMergesAfter(), config.getInternalRefreshListener(),
config.getExternalRefreshListener(), config.getIndexSort(),
config.getInternalRefreshListener(), config.getCircuitBreakerService(),
config.getIndexSort(), config.getGlobalCheckpointSupplier(),
config.getCircuitBreakerService(), config.retentionLeasesSupplier(),
config.getGlobalCheckpointSupplier(), config.getPrimaryTermSupplier(),
config.retentionLeasesSupplier(), config.getTombstoneDocSupplier()
config.getPrimaryTermSupplier(), );
config.getTombstoneDocSupplier() engine.close();
); engine = createEngine(configWithCustomTranslogDeletionPolicyFactory);
try (InternalEngine engine = createEngine(configWithCustomTranslogDeletionPolicyFactory)) { assertTrue(engine.getTranslog().getDeletionPolicy() instanceof CustomTranslogDeletionPolicy);
assertTrue(engine.getTranslog().getDeletionPolicy() instanceof CustomTranslogDeletionPolicy);
}
}
} }
public void testShardNotAvailableExceptionWhenEngineClosedConcurrently() throws IOException, InterruptedException { public void testShardNotAvailableExceptionWhenEngineClosedConcurrently() throws IOException, InterruptedException {