mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
only call refresh if its needed, so we check outside of the readLock when async refreshing
This commit is contained in:
parent
df4f4f056a
commit
7c4d574a32
@ -66,6 +66,11 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
|||||||
|
|
||||||
Searcher searcher() throws EngineException;
|
Searcher searcher() throws EngineException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <tt>true</tt> if a refresh is really needed.
|
||||||
|
*/
|
||||||
|
boolean refreshNeeded();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the engine for new search operations to reflect the latest
|
* Refreshes the engine for new search operations to reflect the latest
|
||||||
* changes. Pass <tt>true</tt> if the refresh operation should include
|
* changes. Pass <tt>true</tt> if the refresh operation should include
|
||||||
|
@ -588,6 +588,10 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean refreshNeeded() {
|
||||||
|
return dirty;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void refresh(Refresh refresh) throws EngineException {
|
@Override public void refresh(Refresh refresh) throws EngineException {
|
||||||
if (indexWriter == null) {
|
if (indexWriter == null) {
|
||||||
throw new EngineClosedException(shardId);
|
throw new EngineClosedException(shardId);
|
||||||
|
@ -607,7 +607,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||||||
private class EngineRefresher implements Runnable {
|
private class EngineRefresher implements Runnable {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
try {
|
try {
|
||||||
engine.refresh(new Engine.Refresh(false));
|
if (engine.refreshNeeded()) {
|
||||||
|
engine.refresh(new Engine.Refresh(false));
|
||||||
|
}
|
||||||
} catch (EngineClosedException e) {
|
} catch (EngineClosedException e) {
|
||||||
// we are being closed, ignore
|
// we are being closed, ignore
|
||||||
} catch (RefreshFailedEngineException e) {
|
} catch (RefreshFailedEngineException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user