You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by "Di Li (JIRA)" <ji...@apache.org> on 2015/09/10 19:02:46 UTC

[jira] [Commented] (AMBARI-12949) Downgrade fails with err: 500 status code received on POST method for API: /api/vi/clusters/mycluster/upgrades

    [ https://issues.apache.org/jira/browse/AMBARI-12949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14739123#comment-14739123 ] 

Di Li commented on AMBARI-12949:
--------------------------------

This seems to be an issue that happens when the "latest" configuration stored in the "clusterconfig" table is for a conf group instead of the default configurations. Caused by the named query "ClusterConfigEntity.findLatestConfigsByStack", where it returns the latest configuration to be set with "selected = 1" in the clusterconfigmapping table. When the "latest" config is for a conf group, this record will not have a corresponding entry in the clusterconfigmapping table. So the clusterconfigmapping table is left with a type that does not have selected set to 1.

Details:

I used Oozie for testing.

When a user clicks the Downgrade button from the Finalize page. The request eventually hits ClusterImpl.applyLatestConfigurations method where the Ambari server updates the database to reverse back to the "latest" configuration of each type for the older stack (HDP 2.2)

The workflow goes as
1. Set ALL entries in clusterconfigmapping table to have selected value set to 0
2. Ambari server uses ClusterImpl.applyLatestConfigurations method to get the "latest" configuration of each type for the older stack (HDP 2.2)
3. Loop through all the entries in the clusterconfigmapping table, and set the selected to 1 if this entry also happens to be in the "latest" configuration returned in step 2.

The ClusterImpl.applyLatestConfigurations method calls ClusterDAO.java getLatestConfigurations to get the latest configuration for each type for the older stack. The DAO class simply runs the following SQL query (cluster id and stack id are the parameters) and passes the results back.

SELECT clusterConfig1 FROM clusterconfig clusterConfig1 WHERE clusterConfig1.cluster_id='2' AND clusterConfig1.create_timestamp = (SELECT MAX(clusterConfig2.create_timestamp) FROM clusterconfig clusterConfig2 WHERE clusterConfig2.cluster_id='2' AND clusterConfig2.stack_id= '3' AND clusterConfig2.type_name = clusterConfig1.type_name);

For downgrade, in our particular use case, the oozie-env configuration stored in the clusterconfig table, when the stack id is the HDP 2.2 version, only contains TWO conf, the original version1 and the one for the config group.

The query above will return the entry corresponding to the oozie config group, as it was the last configuration entry added to the clusterconfig table for oozie-site with stack id = 3. However, because the config group entry is NEVER stored into the clusterconfigmapping table, the logic in ClusterImpl.applyLatestConfigurations method to re-select a version for a type in the clusterconfigmapping will not be able to update the clusterconfigmapping table. Thus no oozie-site is set with selected = 1 in the clusterconfigmapping table.

      for( ClusterConfigEntity clusterConfigToMakeSelected : clusterConfigsToMakeSelected ){
        LOG.info("Checking " + clusterConfigToMakeSelected.getType() + " with tag " + clusterConfigToMakeSelected.getTag());
        for (ClusterConfigMappingEntity configMappingEntity : configMappingEntities) {
          String tag = configMappingEntity.getTag();
          String type = configMappingEntity.getType();
          
          if (clusterConfigToMakeSelected.getTag().equals(tag)
              && clusterConfigToMakeSelected.getType().equals(type)) {
            LOG.info(type + " with tag " + tag + " is selected"); 
            configMappingEntity.setSelected(1);
          }
        }
      }

> Downgrade fails with err: 500 status code received on POST method for API: /api/vi/clusters/mycluster/upgrades
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMBARI-12949
>                 URL: https://issues.apache.org/jira/browse/AMBARI-12949
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-server
>    Affects Versions: 2.1.0
>            Reporter: Di Li
>            Priority: Critical
>
> I have a 4 node HDP 2.2 cluster where I created a configuration group to apply customized oozie_heap_size to the Oozie server and one of the Oozie client. I was able to rolling upgrade the cluster to HDP 2.3, but when I clicked Downgrade button on the Finalize step. The Ambari UI immediately threw error message "500 status code received on POST method for API: /api/vi/clusters/mycluster/upgrades"
> Checking the Ambari server log, it reported a nullpointer error when trying to load the designed configurations
> Aug 30, 2015 11:01:07 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
> SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
> java.lang.NullPointerException
>         at org.apache.ambari.server.state.host.HostImpl.getDesiredHostConfigs(HostImpl.java:1349)
> Digging around in the database, I saw that the oozie-env (where I had a configuration group) had no version_tag set with "selected" as 1.
> Manually setting the version1 row to have selected = 1, restart server and then I was able to run downgrade. However, the downgrade failed to mark itself as finished, and my Ambari WEB UI remained in this "Downgrade:Aborted" state and I can't restart components anymore (as in most of the UI features are disabled as the UI still thinks it's in the middle of an downgrade).
> ambari=> select * from clusterconfigmapping  where type_name = 'oozie-env';
>  cluster_id | type_name |     version_tag      | create_timestamp | selected |   user_name
> ------------+-----------+----------------------+------------------+----------+----------------
>           2 | oozie-env | version1             |    1441033897383 |        0 | admin
>           2 | oozie-env | version1441037586550 |    1441037586592 |        0 | ambari-upgrade
>           2 | oozie-env | version1441039514060 |    1441039516239 |        0 | admin
> (3 rows)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)