|
|
@@ -1359,18 +1359,25 @@ public class InternalEngine extends Engine {
|
|
|
writingBytes.addAndGet(bytes);
|
|
|
try (ReleasableLock lock = readLock.acquire()) {
|
|
|
ensureOpen();
|
|
|
- switch (scope) {
|
|
|
- case EXTERNAL:
|
|
|
- // even though we maintain 2 managers we really do the heavy-lifting only once.
|
|
|
- // the second refresh will only do the extra work we have to do for warming caches etc.
|
|
|
- externalSearcherManager.maybeRefreshBlocking();
|
|
|
- // the break here is intentional we never refresh both internal / external together
|
|
|
- break;
|
|
|
- case INTERNAL:
|
|
|
- internalSearcherManager.maybeRefreshBlocking();
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new IllegalArgumentException("unknown scope: " + scope);
|
|
|
+ if (store.tryIncRef()) {
|
|
|
+ // increment the ref just to ensure nobody closes the store during a refresh
|
|
|
+ try {
|
|
|
+ switch (scope) {
|
|
|
+ case EXTERNAL:
|
|
|
+ // even though we maintain 2 managers we really do the heavy-lifting only once.
|
|
|
+ // the second refresh will only do the extra work we have to do for warming caches etc.
|
|
|
+ externalSearcherManager.maybeRefreshBlocking();
|
|
|
+ // the break here is intentional we never refresh both internal / external together
|
|
|
+ break;
|
|
|
+ case INTERNAL:
|
|
|
+ internalSearcherManager.maybeRefreshBlocking();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException("unknown scope: " + scope);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ store.decRef();
|
|
|
+ }
|
|
|
}
|
|
|
} catch (AlreadyClosedException e) {
|
|
|
failOnTragicEvent(e);
|