Apache Solr open-source search software
SOLR-3745: Proper error reporting if SolrCloud mode is used w/o necessary "_version_" field in schema.xml
Chris M. Hostettera8b57fa9de97
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 88a75309f7e..cda122295ef 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -85,6 +85,9 @@ Bug Fixes* SOLR-3746: Proper error reporting if updateLog is configured w/o necessary"_version_" field in schema.xml (hossman)+* SOLR-3745: Proper error reporting if SolrCloud mode is used w/o+ necessary "_version_" field in schema.xml (hossman)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex 9c1082d8116..5404e3f4549 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -65,6 +65,7 @@ import org.apache.solr.search.ValueSourceParser;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.update.SolrIndexWriter;import org.apache.solr.update.UpdateHandler;+import org.apache.solr.update.VersionInfo;import org.apache.solr.update.processor.DistributedUpdateProcessorFactory;import org.apache.solr.update.processor.LogUpdateProcessorFactory;import org.apache.solr.update.processor.RunUpdateProcessorFactory;@@ -593,6 +594,25 @@ public final class SolrCore implements SolrInfoMBean {schema = new IndexSchema(config, IndexSchema.DEFAULT_SCHEMA_FILE, null);}+ if (null != cd && null != cd.getCloudDescriptor()) {+ // we are evidently running in cloud mode.+ //+ // In cloud mode, version field is required for correct consistency+ // ideally this check would be more fine grained, and individual features+ // would assert it when they initialize, but DistribuedUpdateProcessor+ // is currently a big ball of wax that does more then just distributing+ // updates (ie: partial document updates), so it needs to work in no cloud+ // mode as well, and can't assert version field support on init.++ try {+ Object ignored = VersionInfo.getAndCheckVersionField(schema);+ } catch (SolrException e) {+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,+ "Schema will not work with SolrCloud mode: " ++ e.getMessage(), e);+ }+ }+//Initialize JMXif (config.jmxConfig.enabled) {infoRegistry = new JmxMonitoredMap<String, SolrInfoMBean>(name, String.valueOf(this.hashCode()), config.jmxConfig);