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

Return well formatted error response while deleting host with clients installed.

    XMLWordPrintableJSON

Details

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

    Description

      Deleting host with clients installed, throws 500 server error. It should return well formatted response like
      "message" : "org.apache.ambari.server.controller.spi.SystemException: An internal system exception occurred: Cannot remove host c6403.ambari.apache.org from c1. The following roles exist, and these components must be stopped if running, and then deleted: HDFS_CLIENT"

      Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_hcdesiredstate_host_id" on table "hostcomponentdesiredstate"
        Detail: Key (host_id)=(1) is still referenced from table "hostcomponentdesiredstate".
      Error Code: 0
      Call: DELETE FROM hosts WHERE (host_id = ?)
              bind => [1 parameter bound]
              at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1620)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:900)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:964)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:633)
              at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
              at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.writesCompleted(DatabaseAccessor.java:1845)
              at org.eclipse.persistence.internal.sessions.AbstractSession.writesCompleted(AbstractSession.java:4300)
              at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.writesCompleted(UnitOfWorkImpl.java:5592)
              at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:456)
              at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:874)
              ... 107 more
      Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_hcdesiredstate_host_id" on table "hostcomponentdesiredstate"
        Detail: Key (host_id)=(1) is still referenced from table "hostcomponentdesiredstate".
              at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
              at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
              at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
              at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:892)
              ... 116 more
      

      Attachments

        1. rb48670.patch
          1 kB
          Ajit Kumar

        Issue Links

          Activity

            People

              ajit.kumar Ajit Kumar
              ajit.kumar Ajit Kumar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: