Apache Solr open-source search software
SOLR-10920: Warning for production use of _default configset's data-driven functionality
Ishan Chattopadhyayab29951ff2bd3
diff --git a/solr/bin/solr b/solr/bin/solrindex 3dd0ef8fe11..3d2834057ff 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -978,6 +978,14 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMexit 1fi+ if [ "$CREATE_CONFDIR" == "_default" ]; then+ echo "WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is"+ echo " NOT RECOMMENDED for production use."+ echo+ echo " To turn it off:"+ echo " curl http://$SOLR_TOOL_HOST:$CREATE_PORT/solr/$CREATE_NAME/config -d '{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'"+ fi+if [[ "$(whoami)" == "root" ]] && [[ "$FORCE" == "false" ]] ; thenecho "WARNING: Creating cores as the root user can cause Solr to fail and is not advisable. Exiting."echo " If you started Solr as root (not advisable either), force core creation by adding argument -force"diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex b268f90a767..cfc21b97e58 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -1426,6 +1426,14 @@ if "!CREATE_PORT!"=="" (goto err)++if "!CREATE_CONFDIR!"=="_default" (+ echo WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is+ echo NOT RECOMMENDED for production use.+ echo To turn it off:+ echo curl http://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr/!CREATE_NAME!/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'+)+if "%SCRIPT_CMD%"=="create_core" ("%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.javaindex 7d3df700b09..b136335a7d3 100644--- a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java@@ -284,6 +284,15 @@ public class CreateCollectionCmd implements Cmd {log.info("Cleaned up artifacts for failed create collection for [{}]", collectionName);} else {log.debug("Finished create command on all shards for collection: {}", collectionName);++ // Emit a warning about production use of data driven functionality+ boolean defaultConfigSetUsed = message.getStr(COLL_CONF) == null ||+ message.getStr(COLL_CONF).equals(ConfigSetsHandlerApi.DEFAULT_CONFIGSET_NAME);+ if (defaultConfigSetUsed) {+ results.add("warning", "Using _default configset. Data driven schema functionality"+ + " is enabled by default, which is NOT RECOMMENDED for production use. To turn it off:"+ + " curl http://{host:port}/solr/" + collectionName + "/config -d '{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'");+ }}} catch (SolrException ex) {throw ex;diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.javaindex f2027b0abf7..77db071459a 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java@@ -74,9 +74,10 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {assertEquals(0, (int)status.get("status"));assertTrue(status.get("QTime") > 0);}+ // Use of _default configset should generate a warning for data-driven functionality in production use+ assertTrue(response.getWarning() != null && response.getWarning().contains("NOT RECOMMENDED for production use"));response = CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient());-assertEquals(0, response.getStatus());assertTrue(response.isSuccess());Map<String,NamedList<Integer>> nodesStatus = response.getCollectionNodesStatus();diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.javaindex 6821075b366..c50ef37bfce 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java@@ -35,6 +35,11 @@ public class CollectionAdminResponse extends SolrResponseBasereturn getResponse().get( "success" ) != null;}+ public String getWarning()+ {+ return (String) getResponse().get( "warning" );+ }+// this messages are typically from individual nodes, since// all the failures at the router are propagated as exceptions@SuppressWarnings("unchecked")