You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/02/17 17:23:35 UTC

[GitHub] [lucene-solr] NazerkeBS opened a new pull request #2391: SOLR-1434: Move configName into DocCollection class

NazerkeBS opened a new pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391


   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Lucene or Solr:
   
   * https://issues.apache.org/jira/projects/LUCENE
   * https://issues.apache.org/jira/projects/SOLR
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * LUCENE-####: <short description of problem or changes>
   * SOLR-####: <short description of problem or changes>
   
   LUCENE and SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   Please provide a short description of the changes you're making with this pull request.
   
   # Solution
   
   Please provide a short description of the approach taken to implement your solution.
   
   # Tests
   
   Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `master` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Ref Guide](https://github.com/apache/lucene-solr/tree/master/solr/solr-ref-guide) (for Solr changes only).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] NazerkeBS commented on pull request #2391: SOLR-14341: Move configName into DocCollection class

Posted by GitBox <gi...@apache.org>.
NazerkeBS commented on pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391#issuecomment-799413838


   @dsmiley I closed this PR and created a new PR (https://github.com/apache/solr/pull/17 ) on the main branch due to conflicts. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] NazerkeBS closed pull request #2391: SOLR-14341: Move configName into DocCollection class

Posted by GitBox <gi...@apache.org>.
NazerkeBS closed pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] NazerkeBS commented on a change in pull request #2391: SOLR-14341: Move configName into DocCollection class

Posted by GitBox <gi...@apache.org>.
NazerkeBS commented on a change in pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391#discussion_r580973494



##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -84,7 +88,10 @@ public DocCollection(String name, Map<String, Slice> slices, Map<String, Object>
    * @param zkVersion The version of the Collection node in Zookeeper (used for conditional updates).
    */
   public DocCollection(String name, Map<String, Slice> slices, Map<String, Object> props, DocRouter router, int zkVersion) {
-    super(props==null ? props = new HashMap<>() : props);
+    super(props);
+    if (props == null || props.containsKey("baseConfigSet")) {

Review comment:
       this was outdated




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dsmiley commented on a change in pull request #2391: SOLR-14341: Move configName into DocCollection class

Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391#discussion_r578958566



##########
File path: solr/core/src/java/org/apache/solr/cloud/CloudConfigSetService.java
##########
@@ -86,12 +86,11 @@ public SolrResourceLoader createCoreResourceLoader(CoreDescriptor cd) {
 
     // The configSet is read from ZK and populated.  Ignore CD's pre-existing configSet; only populated in standalone
     final String configSetName;
-    try {
-      configSetName = zkController.getZkStateReader().readConfigName(colName);
-      cd.setConfigSet(configSetName);
-    } catch (KeeperException ex) {
-      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "Trouble resolving configSet for collection " + colName + ": " + ex.getMessage());
+    configSetName = zkController.getZkStateReader().getClusterState().getCollection(colName).getConfigName();
+    if (configSetName == null) {

Review comment:
       I think we can have getConfigName never return null?  That would be ideal, any way.

##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java
##########
@@ -166,7 +166,7 @@ public void call(ClusterState state, ZkNodeProps message, @SuppressWarnings({"ra
       }
 
       // delete related config set iff: it is auto generated AND not related to any other collection
-      String configSetName = zkStateReader.readConfigName(collection);
+      String configSetName = message.getStr(ZkStateReader.COLLECTION_CONFIG_PROP, coll.getConfigName());

Review comment:
       Like my last comment; I'm unsure `message` has the configSet

##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/BackupCmd.java
##########
@@ -81,7 +82,7 @@ public void call(ClusterState state, ZkNodeProps message, @SuppressWarnings({"ra
     String backupName = message.getStr(NAME);
     String repo = message.getStr(CoreAdminParams.BACKUP_REPOSITORY);
     boolean incremental = message.getBool(CoreAdminParams.BACKUP_INCREMENTAL, true);
-    String configName = ocmh.zkStateReader.readConfigName(collectionName);
+    String configName = message.getStr(ZkStateReader.COLLECTION_CONFIG_PROP);

Review comment:
       Are you sure that `message` contains the configSet?  (Maybe it does; I don't know).  But what I do know is that you can look it up from DocCollection now.

##########
File path: solr/core/src/java/org/apache/solr/cloud/overseer/CollectionMutator.java
##########
@@ -99,7 +100,7 @@ public ZkWriteCommand deleteShard(final ClusterState clusterState, ZkNodeProps m
   }
 
   public ZkWriteCommand modifyCollection(final ClusterState clusterState, ZkNodeProps message) {
-    if (!checkCollectionKeyExistence(message)) return ZkStateWriter.NO_OP;
+    if (!checkCollectionKeyExistence(message) || !checkKeyExistence(message, ZkStateReader.COLLECTION_CONFIG_PROP)) return ZkStateWriter.NO_OP;

Review comment:
       This change is curious to me.    Does this mean the configSet (aka configName in much of the naming) is mandatory for modifying a collection?  If so, that seems wrong.

##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -84,7 +88,10 @@ public DocCollection(String name, Map<String, Slice> slices, Map<String, Object>
    * @param zkVersion The version of the Collection node in Zookeeper (used for conditional updates).
    */
   public DocCollection(String name, Map<String, Slice> slices, Map<String, Object> props, DocRouter router, int zkVersion) {
-    super(props==null ? props = new HashMap<>() : props);
+    super(props);
+    if (props == null || props.containsKey("baseConfigSet")) {

Review comment:
       Why the name "baseConfigSet"?  And if it is in props, wouldn't we end up over-writing CONFIGNAME_PROP if it's there?
   
   If props is null, how do we call props.put without getting an NPE?

##########
File path: solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
##########
@@ -139,14 +139,9 @@ public void getClusterStatus(@SuppressWarnings({"rawtypes"})NamedList results)
       if (collectionVsAliases.containsKey(name) && !collectionVsAliases.get(name).isEmpty()) {
         collectionStatus.put("aliases", collectionVsAliases.get(name));
       }
-      try {
-        String configName = zkStateReader.readConfigName(name);
-        collectionStatus.put("configName", configName);
-        collectionProps.add(name, collectionStatus);
-      } catch (KeeperException.NoNodeException ex) {
-        // skip this collection because the configset's znode has been deleted
-        // which can happen during aggressive collection removal, see SOLR-10720
-      }
+      String configName = message.getStr(ZkStateReader.COLLECTION_CONFIG_PROP, clusterStateCollection.getConfigName());

Review comment:
       The message didn't have this before (I assume?); does it now?

##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -119,6 +126,10 @@ public DocCollection(String name, Map<String, Slice> slices, Map<String, Object>
     this.activeSlicesArr = activeSlices.values().toArray(new Slice[activeSlices.size()]);
     this.router = router;
     this.znode = ZkStateReader.getCollectionPath(name);
+    this.configName = String.valueOf(props.get(CONFIGNAME_PROP)) == null ? String.valueOf(props.get(COLLECTION_CONFIG_PROP)) : String.valueOf(props.get(CONFIGNAME_PROP));

Review comment:
       Pick one -- probably CONFIGNAME_PROP, not also COLLECTION_CONFIG_PROP.  I believe COLLECTION_CONFIG_PROP is only used at the HTTP API level, not internally.

##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -289,6 +300,8 @@ public Integer getReplicationFactor() {
     return replicationFactor;
   }
 
+  public String getConfigName() { return configName; }

Review comment:
       Add a javadoc to say does not return null.

##########
File path: solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
##########
@@ -91,7 +91,7 @@ public static StorageIO newStorageIO(String collection, SolrResourceLoader resou
       zkClient = ((ZkSolrResourceLoader)resourceLoader).getZkController().getZkClient();
       try {
         zkConfigName = ((ZkSolrResourceLoader)resourceLoader).getZkController().
-            getZkStateReader().readConfigName(collection);
+            getZkStateReader().getClusterState().getCollection(collection).getConfigName();

Review comment:
       BTW for brevity, you can remove `getZkStateReader().` here and elsewhere since ZkController has a convenience method for the cluster state.

##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
##########
@@ -128,6 +128,7 @@
 
   public static final String CONFIGS_ZKNODE = "/configs";
   public final static String CONFIGNAME_PROP = "configName";
+  public final static String COLLECTION_CONFIG_PROP = "collection.configName";

Review comment:
       Probably doesn't go here because I think it's specific to the HTTP API layer.  This class is too internal to declare such a name.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dsmiley commented on a change in pull request #2391: SOLR-14341: Move configName into DocCollection class

Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #2391:
URL: https://github.com/apache/lucene-solr/pull/2391#discussion_r590352385



##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -300,6 +307,9 @@ public Integer getReplicationFactor() {
     return replicationFactor;
   }
 
+  /**
+   * Return non-null configName.

Review comment:
       ```suggestion
      * Return non-null configset name.
   ```

##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
##########
@@ -88,10 +88,17 @@ public DocCollection(String name, Map<String, Slice> slices, Map<String, Object>
    * @param zkVersion The version of the Collection node in Zookeeper (used for conditional updates).
    */
   public DocCollection(String name, Map<String, Slice> slices, Map<String, Object> props, DocRouter router, int zkVersion) {
-    super(props);
-    if (props == null || props.containsKey("baseConfigSet")) {
+    if (props == null) {

Review comment:
       null || props.isEmpty() can be combined

##########
File path: solr/core/src/java/org/apache/solr/cloud/CloudConfigSetService.java
##########
@@ -86,12 +86,11 @@ public SolrResourceLoader createCoreResourceLoader(CoreDescriptor cd) {
 
     // The configSet is read from ZK and populated.  Ignore CD's pre-existing configSet; only populated in standalone
     final String configSetName;
-    try {
-      configSetName = zkController.getZkStateReader().readConfigName(colName);
-      cd.setConfigSet(configSetName);
-    } catch (KeeperException ex) {
-      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "Trouble resolving configSet for collection " + colName + ": " + ex.getMessage());
+    configSetName = zkController.getZkStateReader().getClusterState().getCollection(colName).getConfigName();
+    if (configSetName == null) {

Review comment:
       still an issue?

##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
##########
@@ -554,12 +554,11 @@ private void modifyCollection(ClusterState clusterState, ZkNodeProps message, @S
     final String collectionName = message.getStr(ZkStateReader.COLLECTION_PROP);
     //the rest of the processing is based on writing cluster state properties
     //remove the property here to avoid any errors down the pipeline due to this property appearing
-    String configName = (String) message.getProperties().remove(CollectionAdminParams.COLL_CONF);
+    String configName = (String) message.getProperties().get(CollectionAdminParams.COLL_CONF);

Review comment:
       just observing that this innocent looking change seems important to this PR.  Previously this data had disappeared from the state.

##########
File path: solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java
##########
@@ -367,12 +367,7 @@ private void deleteConfigSet(String configSetName, boolean force) throws IOExcep
 
     for (Map.Entry<String, DocCollection> entry : zkStateReader.getClusterState().getCollectionsMap().entrySet()) {
       String configName = null;
-      try {
-        configName = zkStateReader.readConfigName(entry.getKey());
-      } catch (KeeperException ex) {
-        throw new SolrException(ErrorCode.BAD_REQUEST,
-            "Can not delete ConfigSet as it is currently being used by collection [" + entry.getKey() + "]");
-      }
+      configName = entry.getValue().getConfigName();

Review comment:
       combine declaration and initialization




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org