Call onNewEngine before the engine is actually published

This commit is contained in:
Simon Willnauer 2016-09-19 17:00:17 +02:00
parent 817d55cf93
commit bd93b3dce6
1 changed files with 4 additions and 3 deletions

View File

@ -992,7 +992,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
// but we need to make sure we don't loose deletes until we are done recovering
config.setEnableGcDeletes(false);
Engine newEngine = createNewEngine(config);
onNewEngine(newEngine);
verifyNotClosed();
if (openMode == EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG) {
// We set active because we are now writing operations to the engine; this way, if we go idle after some time and become inactive,
@ -1552,8 +1551,10 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
throw new EngineClosedException(shardId);
}
assert this.currentEngineReference.get() == null;
this.currentEngineReference.set(newEngine(config));
Engine engine = newEngine(config);
onNewEngine(engine); // call this before we pass the memory barrier otherwise actions that happen
// inside the callback are not visible. This one enforces happens-before
this.currentEngineReference.set(engine);
}
// time elapses after the engine is created above (pulling the config settings) until we set the engine reference, during which