-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42319/
-----------------------------------------------------------

(Updated Jan. 15, 2016, 8:38 a.m.)


Review request for Ambari, Alejandro Fernandez, Jayush Luniya, and Nate Cole.


Changes
-------

Found under certain circumstances removing entities from lists doesn't actually 
instruct JPA to remove that element from the EntityManager, resulting in a 
detached entity merge. Was able to reproduce in a test case (yay!)


Bugs: AMBARI-14674
    https://issues.apache.org/jira/browse/AMBARI-14674


Repository: ambari


Description
-------

RU HDP 2.2 to 2.4 downgrade results in:

{code}
java.lang.IllegalArgumentException: Can not refresh not managed object: 
org.apache.ambari.server.orm.entities.ClusterEntity@18126.
        at 
org.eclipse.persistence.internal.jpa.EntityManagerImpl.refresh(EntityManagerImpl.java:1024)
        at 
org.eclipse.persistence.internal.jpa.EntityManagerImpl.refresh(EntityManagerImpl.java:929)
        at 
org.apache.ambari.server.orm.dao.ClusterDAO.refresh(ClusterDAO.java:309)
        at 
org.apache.ambari.server.orm.AmbariJpaLocalTxnInterceptor.invoke(AmbariJpaLocalTxnInterceptor.java:68)
        at 
org.apache.ambari.server.state.cluster.ClusterImpl.removeConfigurations(ClusterImpl.java:3216)
        at 
org.apache.ambari.server.serveraction.upgrades.FinalizeUpgradeAction.finalizeDowngrade(FinalizeUpgradeAction.java:314)
    ...
{code}

It seems like what's happening is that the ClusterEntity is being retrieved 
outside of a JPA session. Although the ClusterDAO creates the session, it also 
ends it, leaving the Entity detached. We should instead be refreshing this 
Entity within the bounds of the Transaction.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java 
22bd8bb 
  
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
 3938e31 
  
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
 3d00c29 
  
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
 d2ba396 

Diff: https://reviews.apache.org/r/42319/diff/


Testing (updated)
-------

mvn clean test


Thanks,

Jonathan Hurley

Reply via email to