mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-03 17:39:15 +00:00
Merge pull request #16118 from s1monw/refresh_all_the_time_if_api
Don't guard IndexShard#refresh calls by a check to isRefreshNeeded
This commit is contained in:
commit
d11a11e9f0
@ -635,7 +635,9 @@ public final class IndexService extends AbstractIndexComponent implements IndexC
|
|||||||
case STARTED:
|
case STARTED:
|
||||||
case RELOCATED:
|
case RELOCATED:
|
||||||
try {
|
try {
|
||||||
shard.refresh("schedule");
|
if (shard.isRefreshNeeded()) {
|
||||||
|
shard.refresh("schedule");
|
||||||
|
}
|
||||||
} catch (EngineClosedException | AlreadyClosedException ex) {
|
} catch (EngineClosedException | AlreadyClosedException ex) {
|
||||||
// fine - continue;
|
// fine - continue;
|
||||||
}
|
}
|
||||||
|
@ -541,25 +541,23 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|||||||
/** Writes all indexing changes to disk and opens a new searcher reflecting all changes. This can throw {@link EngineClosedException}. */
|
/** Writes all indexing changes to disk and opens a new searcher reflecting all changes. This can throw {@link EngineClosedException}. */
|
||||||
public void refresh(String source) {
|
public void refresh(String source) {
|
||||||
verifyNotClosed();
|
verifyNotClosed();
|
||||||
if (getEngine().refreshNeeded()) {
|
if (canIndex()) {
|
||||||
if (canIndex()) {
|
long bytes = getEngine().getIndexBufferRAMBytesUsed();
|
||||||
long bytes = getEngine().getIndexBufferRAMBytesUsed();
|
writingBytes.addAndGet(bytes);
|
||||||
writingBytes.addAndGet(bytes);
|
try {
|
||||||
try {
|
logger.debug("refresh with source [{}] indexBufferRAMBytesUsed [{}]", source, new ByteSizeValue(bytes));
|
||||||
logger.debug("refresh with source [{}] indexBufferRAMBytesUsed [{}]", source, new ByteSizeValue(bytes));
|
|
||||||
long time = System.nanoTime();
|
|
||||||
getEngine().refresh(source);
|
|
||||||
refreshMetric.inc(System.nanoTime() - time);
|
|
||||||
} finally {
|
|
||||||
logger.debug("remove [{}] writing bytes for shard [{}]", new ByteSizeValue(bytes), shardId());
|
|
||||||
writingBytes.addAndGet(-bytes);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.debug("refresh with source [{}]", source);
|
|
||||||
long time = System.nanoTime();
|
long time = System.nanoTime();
|
||||||
getEngine().refresh(source);
|
getEngine().refresh(source);
|
||||||
refreshMetric.inc(System.nanoTime() - time);
|
refreshMetric.inc(System.nanoTime() - time);
|
||||||
|
} finally {
|
||||||
|
logger.debug("remove [{}] writing bytes for shard [{}]", new ByteSizeValue(bytes), shardId());
|
||||||
|
writingBytes.addAndGet(-bytes);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.debug("refresh with source [{}]", source);
|
||||||
|
long time = System.nanoTime();
|
||||||
|
getEngine().refresh(source);
|
||||||
|
refreshMetric.inc(System.nanoTime() - time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1514,4 +1512,15 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|||||||
return engineFactory;
|
return engineFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> iff one or more changes to the engine are not visible to via the current searcher.
|
||||||
|
* Otherwise <code>false</code>.
|
||||||
|
*
|
||||||
|
* @throws EngineClosedException if the engine is already closed
|
||||||
|
* @throws AlreadyClosedException if the internal indexwriter in the engine is already closed
|
||||||
|
*/
|
||||||
|
public boolean isRefreshNeeded() {
|
||||||
|
return getEngine().refreshNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user