SOLR-4926: SolrDeletionPolicy.getLatestCommit can be null before IW is used

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1498554 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2013-07-01 16:33:55 +00:00
parent 8227df4c04
commit d96faa4a3a
1 changed files with 18 additions and 1 deletions

View File

@ -318,8 +318,25 @@ public class SnapPuller {
long latestVersion = (Long) response.get(CMD_INDEX_VERSION); long latestVersion = (Long) response.get(CMD_INDEX_VERSION);
long latestGeneration = (Long) response.get(GENERATION); 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(); 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<SolrIndexSearcher> 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 (latestVersion == 0L) {
if (forceReplication && commit.getGeneration() != 0) { if (forceReplication && commit.getGeneration() != 0) {
// since we won't get the files for an empty index, // since we won't get the files for an empty index,