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:
parent
37ac3788a3
commit
12789f89a3
|
@ -3807,38 +3807,35 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
}
|
||||
TranslogDeletionPolicyFactory translogDeletionPolicyFactory = CustomTranslogDeletionPolicy::new;
|
||||
|
||||
try (Store store = createStore()) {
|
||||
EngineConfig config = engine.config();
|
||||
|
||||
EngineConfig configWithCustomTranslogDeletionPolicyFactory = new EngineConfig(
|
||||
config.getShardId(),
|
||||
config.getThreadPool(),
|
||||
config.getIndexSettings(),
|
||||
config.getWarmer(),
|
||||
store,
|
||||
config.getMergePolicy(),
|
||||
config.getAnalyzer(),
|
||||
config.getSimilarity(),
|
||||
new CodecService(null, logger),
|
||||
config.getEventListener(),
|
||||
config.getQueryCache(),
|
||||
config.getQueryCachingPolicy(),
|
||||
config.getTranslogConfig(),
|
||||
translogDeletionPolicyFactory,
|
||||
config.getFlushMergesAfter(),
|
||||
config.getExternalRefreshListener(),
|
||||
config.getInternalRefreshListener(),
|
||||
config.getIndexSort(),
|
||||
config.getCircuitBreakerService(),
|
||||
config.getGlobalCheckpointSupplier(),
|
||||
config.retentionLeasesSupplier(),
|
||||
config.getPrimaryTermSupplier(),
|
||||
config.getTombstoneDocSupplier()
|
||||
);
|
||||
try (InternalEngine engine = createEngine(configWithCustomTranslogDeletionPolicyFactory)) {
|
||||
assertTrue(engine.getTranslog().getDeletionPolicy() instanceof CustomTranslogDeletionPolicy);
|
||||
}
|
||||
}
|
||||
EngineConfig config = engine.config();
|
||||
EngineConfig configWithCustomTranslogDeletionPolicyFactory = new EngineConfig(
|
||||
config.getShardId(),
|
||||
config.getThreadPool(),
|
||||
config.getIndexSettings(),
|
||||
config.getWarmer(),
|
||||
config.getStore(),
|
||||
config.getMergePolicy(),
|
||||
config.getAnalyzer(),
|
||||
config.getSimilarity(),
|
||||
new CodecService(null, logger),
|
||||
config.getEventListener(),
|
||||
config.getQueryCache(),
|
||||
config.getQueryCachingPolicy(),
|
||||
config.getTranslogConfig(),
|
||||
translogDeletionPolicyFactory,
|
||||
config.getFlushMergesAfter(),
|
||||
config.getExternalRefreshListener(),
|
||||
config.getInternalRefreshListener(),
|
||||
config.getIndexSort(),
|
||||
config.getCircuitBreakerService(),
|
||||
config.getGlobalCheckpointSupplier(),
|
||||
config.retentionLeasesSupplier(),
|
||||
config.getPrimaryTermSupplier(),
|
||||
config.getTombstoneDocSupplier()
|
||||
);
|
||||
engine.close();
|
||||
engine = createEngine(configWithCustomTranslogDeletionPolicyFactory);
|
||||
assertTrue(engine.getTranslog().getDeletionPolicy() instanceof CustomTranslogDeletionPolicy);
|
||||
}
|
||||
|
||||
public void testShardNotAvailableExceptionWhenEngineClosedConcurrently() throws IOException, InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue