Merge pull request #12640 from s1monw/issues/12603

Ignore EngineClosedException on IndexShard#sync
This commit is contained in:
Simon Willnauer 2015-08-04 15:57:51 +02:00
commit 8e250d6072
2 changed files with 4 additions and 7 deletions

View File

@ -211,12 +211,7 @@ public class TransportIndexAction extends TransportReplicationAction<IndexReques
}
if (indexShard.getTranslogDurability() == Translog.Durabilty.REQUEST && location != null) {
try {
indexShard.sync(location);
} catch (EngineClosedException e) {
// ignore, the engine is already closed and we do not want the
// operation to be retried, because it has been modified
}
}
}
}

View File

@ -1403,9 +1403,11 @@ public class IndexShard extends AbstractIndexShardComponent {
* Syncs the given location with the underlying storage unless already synced.
*/
public void sync(Translog.Location location) {
final Engine engine = engine();
try {
final Engine engine = engine();
engine.getTranslog().ensureSynced(location);
} catch (EngineClosedException ex) {
// that's fine since we already synced everything on engine close - this also is conform with the methods documentation
} catch (IOException ex) { // if this fails we are in deep shit - fail the request
logger.debug("failed to sync translog", ex);
throw new ElasticsearchException("failed to sync translog", ex);