You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2017/07/09 11:35:58 UTC

lucene-solr:jira/solr-10920: SOLR-10920: Warning for production use of _default configset's data-driven functionality

Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-10920 [created] b29951ff2


SOLR-10920: Warning for production use of _default configset's data-driven functionality


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b29951ff
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b29951ff
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b29951ff

Branch: refs/heads/jira/solr-10920
Commit: b29951ff2bd317dfe3b1e705c5f8d612fc683317
Parents: cd2f635
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Sun Jul 9 17:05:38 2017 +0530
Committer: Ishan Chattopadhyaya <is...@apache.org>
Committed: Sun Jul 9 17:05:38 2017 +0530

----------------------------------------------------------------------
 solr/bin/solr                                               | 8 ++++++++
 solr/bin/solr.cmd                                           | 8 ++++++++
 .../src/java/org/apache/solr/cloud/CreateCollectionCmd.java | 9 +++++++++
 .../test/org/apache/solr/cloud/CollectionsAPISolrJTest.java | 3 ++-
 .../solr/client/solrj/response/CollectionAdminResponse.java | 5 +++++
 5 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b29951ff/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 3dd0ef8..3d28340 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -978,6 +978,14 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
     exit 1
   fi
 
+  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" ]] ; then
     echo "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"

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b29951ff/solr/bin/solr.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index b268f90..cfc21b9 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" ^

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b29951ff/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
index 7d3df70..b136335 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;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b29951ff/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
index f2027b0..77db071 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();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b29951ff/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java
----------------------------------------------------------------------
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.java
index 6821075..c50ef37 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 SolrResponseBase
     return 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")