Tom Beerbower created AMBARI-5871:
-------------------------------------

             Summary: Views: Can't install new instance after deploying view 
instance
                 Key: AMBARI-5871
                 URL: https://issues.apache.org/jira/browse/AMBARI-5871
             Project: Ambari
          Issue Type: Bug
    Affects Versions: 1.6.0
            Reporter: Tom Beerbower
            Assignee: Tom Beerbower


After setting up sevaral instances and restart ambari after every creating 
instance, I'm starting to get this error:
{noformat}
The attribute [view] of class 
[org.apache.ambari.server.orm.entities.ViewInstanceEntity] is mapped to a 
primary key column in the database. Updates are not allowed.
{noformat}
In logs after restarting server

Setting up one view, e.g. FILES (put jar to resources, restart ambari, create 
instance through API, again restart) is ok.
Then, if I want to install one another ambari view (e.g. PIG) I'm getting error 
on creating instance (POST request to 
/api/v1/views/PIG/versions/0.1.0/instances/PIG_1 returns 500). In logs I see 
this

{noformat}
javax.persistence.RollbackException: java.lang.IllegalStateException: During 
synchronization a new object was found through a relationship that was not 
marked cascade PERSIST: 
org.apache.ambari.server.orm.entities.ViewEntity@2260898b.
        at 
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
        at 
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
        at 
org.apache.ambari.server.orm.AmbariJpaLocalTxnInterceptor.invoke(AmbariJpaLocalTxnInterceptor.java:91)
        at 
org.apache.ambari.server.view.ViewRegistry.installViewInstance(ViewRegistry.java:351)
        at 
org.apache.ambari.server.controller.internal.ViewInstanceResourceProvider$1.invoke(ViewInstanceResourceProvider.java:289)
        at 
org.apache.ambari.server.controller.internal.ViewInstanceResourceProvider$1.invoke(ViewInstanceResourceProvider.java:286)
        at 
org.apache.ambari.server.controller.internal.AbstractResourceProvider.createResources(AbstractResourceProvider.java:237)
        at 
org.apache.ambari.server.controller.internal.ViewInstanceResourceProvider.createResources(ViewInstanceResourceProvider.java:107)
        at 
org.apache.ambari.server.controller.internal.ClusterControllerImpl.createResources(ClusterControllerImpl.java:218)
        at 
org.apache.ambari.server.api.services.persistence.PersistenceManagerImpl.create(PersistenceManagerImpl.java:75)
...
{noformat}

I'm not getting error if I install FILES and PIG in one shot (create both 
instances without restarting ambari after each one)

Steps to reproduce ...

1) download files.jar
2) restart ambari
3) create instance for FILES
4) restart ambari (and ensure that all works)
5) download pig.jar
6) restart ambari
7) create instance for PIG (got error here)

The problem is that deployment of the views are not isolated from each other. 
So the code reads the archives and builds up the registry for all of the views, 
then it persists any views that aren't already persisted, then it deploys them 
all to the Jetty container. There is a situation where all the view archives 
get read followed by a failure trying to persist one of the views view. The 
failure causes the whole process of view deployment to stop so none of the 
views get deployed to Jetty.

Inn this scenario, even though a view doesn't get persisted, it is in the view 
registry which means that it shows up in the API. This means that the user can 
invoke the API to create an instance but it fails because the view is only 
partially deployed (not in the DB).




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to