diff --git a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java index be83de94eab..2a31d2b9000 100644 --- a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java +++ b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java @@ -318,8 +318,25 @@ public class SnapPuller { long latestVersion = (Long) response.get(CMD_INDEX_VERSION); long latestGeneration = (Long) response.get(GENERATION); + // TODO: make sure that getLatestCommit only returns commit points for the main index (i.e. no side-car indexes) IndexCommit commit = core.getDeletionPolicy().getLatestCommit(); - + if (commit == null) { + // Presumably the IndexWriter hasn't been opened yet, and hence the deletion policy hasn't been updated with commit points + RefCounted searcherRefCounted = null; + try { + searcherRefCounted = core.getNewestSearcher(false); + if (searcherRefCounted == null) { + LOG.warn("No open searcher found - fetch aborted"); + return false; + } + commit = searcherRefCounted.get().getIndexReader().getIndexCommit(); + } finally { + if (searcherRefCounted != null) + searcherRefCounted.decref(); + } + } + + if (latestVersion == 0L) { if (forceReplication && commit.getGeneration() != 0) { // since we won't get the files for an empty index,