Ignore closed exception on refresh pending location listener (#55799)

This newly added listener should catch closed exceptions when
accessing the internal engine.

Closes #55792
This commit is contained in:
Jim Ferenczi 2020-04-27 15:05:47 +02:00 committed by jimczi
parent abab4c4d4f
commit b5916ac455
1 changed files with 7 additions and 2 deletions

View File

@ -3288,12 +3288,17 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
@Override
public void beforeRefresh() {
lastWriteLocation = getEngine().getTranslogLastWriteLocation();
try {
lastWriteLocation = getEngine().getTranslogLastWriteLocation();
} catch (AlreadyClosedException exc) {
// shard is closed - no location is fine
lastWriteLocation = null;
}
}
@Override
public void afterRefresh(boolean didRefresh) {
if (didRefresh) {
if (didRefresh && lastWriteLocation != null) {
pendingRefreshLocation.updateAndGet(pendingLocation -> {
if (pendingLocation == null || pendingLocation.compareTo(lastWriteLocation) <= 0) {
return null;