Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-1129

Updating service configuration for a service via the api fails with a sql error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2.0
    • 1.2.0
    • ambari-server
    • None

    Description

      In ServiceConfigMappingDAO, the where clause of the sql query is built incorrectly. In the below code snippet, the argument "?5" is used in the where clause and there are only three arguments that get set. The 5 should be changed to a 3.

      TypedQuery<ServiceConfigMappingEntity> query =
      entityManagerProvider.get().createQuery(
      "SELECT config FROM ServiceConfigMappingEntity config"
      + " WHERE "
      + " config.clusterId = ?1"
      + " AND config.serviceName = ?2"
      + " AND config.configType IN ?5",
      ServiceConfigMappingEntity.class);
      return daoUtils.selectList(query, clusterId, serviceName, configTypes);

      As a result, the query fails because there is no arg 5. This results in the below stack trace:

      java.lang.IllegalArgumentException: You have attempted to set a parameter at position 3 which does not exist in this query string SELECT config FROM ServiceConfigMappingEntity config WHERE config.clusterId = ?1 AND config.serviceName = ?2 AND config.configType IN ?5.
      at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:820)
      at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:801)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:451)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:1)
      at org.apache.ambari.server.orm.dao.DaoUtils.setParameters(DaoUtils.java:57)
      at org.apache.ambari.server.orm.dao.DaoUtils.selectList(DaoUtils.java:33)
      at org.apache.ambari.server.orm.dao.ServiceConfigMappingDAO.findByServiceAndType(ServiceConfigMappingDAO.java:63)
      at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66)
      at org.apache.ambari.server.orm.dao.ClearEntityManagerInterceptor.invoke(ClearEntityManagerInterceptor.java:41)
      at org.apache.ambari.server.state.ServiceImpl.updateDesiredConfigs(ServiceImpl.java:296)
      at org.apache.ambari.server.controller.AmbariManagementControllerImpl.updateServices(AmbariManagementControllerImpl.java:2107)
      ...

      Attachments

        1. AMBARI-1129.patch
          3 kB
          John Speidel

        Activity

          People

            jspeidel John Speidel
            jspeidel John Speidel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: