12 Replies Latest reply on May 31, 2012 3:31 PM by shawkins

    Issue on VDB deployment order

    buntylava

      Hi,

       

      I am working on a EJB project which uses JPA. JPA is configured with teiid as datasource and have defined dynamic vdb's, since the load order of the VDB's is after the EJB's and the EJB persistence unit looks for the datasource on start of EJB deployment, there will be exceptions as the VDB has not been deployed yet.

       

      Exception -----------------------------------------------------------------------------------------------------------------------------------

      org.teiid.jdbc.TeiidSQLException: VDB "test-dynamic-vdb" version "latest" is not in the "active" status.

          at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:113)

          at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:70)

          at org.teiid.jdbc.SocketProfile.connect(SocketProfile.java:56)

          at org.teiid.jdbc.TeiidDriver.connect(TeiidDriver.java:107)

          at org.teiid.jdbc.TeiidDataSource.getConnection(TeiidDataSource.java:249)

          at org.teiid.jdbc.BaseDataSource$1.createConnection(BaseDataSource.java:356)

          at org.teiid.jdbc.XAConnectionImpl.getConnectionImpl(XAConnectionImpl.java:132)

          at org.teiid.jdbc.XAConnectionImpl.getConnection(XAConnectionImpl.java:118)

      ----------------------------------------------------------------------------------------------------------------------------------------------------

       

      If the order is changed by setting a entry for the VDB to be before EJB's deployment order in Jboss deployers.xml, even then there is a problem, as the dynamic vdb on deployment will start loading DB schema metadata and during this loading the state od the vdb will be inactive state and will be set to active only after the metadata load is completed, if the EJB deployment starts before the the state of the vdb is active, even then there will be exceptions.

       

      How can i solve this?

       

      Can I make the EAR to deploy only after the vdb is deployed and when active?

        • 1. Re: Issue on VDB deployment order
          shawkins

          bunty,

           

          Is the EJB obtaining a connection, or is this caused by pool pre-population?  If it's the latter, then set the min pool size to 0. 

           

          If the EJB layer still has issues with inactive connections, then we probably want to consider adding a connection option to make the connection blocking until active.

           

          Steve

          • 2. Re: Issue on VDB deployment order
            buntylava

            JPA entity mappings are validated with datasource by obtaining a connections on deployment , I have tested my setting the pool size to 0, which has no effect. Can a dependency configuration be made using jboss-dependencies.xml or jboss-deployment.xml?

            • 3. Re: Issue on VDB deployment order
              shawkins

              The VDBDeployer is hard-coded to use a relative deployment order of 3001, which is after the data sources are loaded. jboss-dependency.xml may be of some help, however there is no service/bean representing the active state of a VDB.  It seems like an enhancement will be required.

              1 of 1 people found this helpful
              • 4. Re: Issue on VDB deployment order
                buntylava

                Hi Steven,

                 

                     If the service/bean representation for the VDB state is not available then jboss-dependencies.xml would not help for dynamic vdb deployment scenario. It does seem like a enhancement. Thanks for sharing the thoughts. Please update if found some way.I will do the same from my end, thanks again

                 

                Thanks

                • 5. Re: Issue on VDB deployment order
                  rareddy

                  Bunty,

                   

                  One workaround is deploying the Teiid Dynamic VDB in a separate JBoss AS instance than same instance EJB in.

                   

                  The dependecy stuff you could possibly do it in the Teiid 8.0 with JBoss AS 7.1.1. In 7.7 changing the deployment order after EJB deployment number may work?

                   

                  Ramesh..

                  • 6. Re: Issue on VDB deployment order
                    markaddleman

                    If I understand correctly, we have a similar need:  Our application's VDB relies on subordinate VDBs to obtain structural information that gets processed in our app's translator's getMetadata method.  Therefore, the application VDB should not start until the subordinate VDB is ready.

                     

                    Currently, the application VDB polls the subordinate VDB waiting for it to be ready.  Our application also dynamically produces VDBs using Teiid's admin API so a JBoss beans notification would be cumbersome.  A callback mechanism from the Admin api would be preferable.

                     

                    If this makes sense, I'll submit a jira

                    • 7. Re: Issue on VDB deployment order
                      rareddy

                      Admin interface can *not* be used with push model. It is pull only. This is based on JBoss AS profile services.

                      • 8. Re: Issue on VDB deployment order
                        shawkins

                        For 7.7 the simplest enhancement would be to just add optional vdb polling into the JDBC connection logic, unless Ramesh you know of some other AS tricks we could employ.

                         

                        For 8.1 it would probably make sense to rethink the whole status active/inactive logic.  It was a fairly clean concept back in the MMX days, however now it is inconsistent as datasources can be removed indepenently of consuming vdbs.  So transitioning to the inactive state is meaningless to connections that have already been made.

                         

                        I would propose using the statuses:

                        LOADING

                        ACTIVE

                        INVALID - if there is a metadata validation failure or a source missing

                         

                        We would also change the logic to not inhibit making a connection regardless of the status.  The DQP getMetadata and executeRequest calls are the only ones that would need to enforce that the vdb is out of the loading state before proceeding.  To make this work as an asynch callback getMetadata would also need to return a Future and the work on those would delayed until a vdblifecyclelistener reports that the target vdb has finished loading.

                         

                        As long as the engine is running and the vdb is deployed, then client connections will succeed.  The question would then be for local jndi connections how do we wait until the vdb is deployed.  Ramesh is there a simply way in the AS to have a DataSource dependent upon a VDBService?

                        • 9. Re: Issue on VDB deployment order
                          rareddy

                          All I was thinking is checking out the EJB deployer's deployment order and make VDB deployment order after it, do not know if that is sufficient.

                           

                          I do not think we can create a dependency on foreign services, you can only listen to their events.

                          • 10. Re: Issue on VDB deployment order
                            markaddleman

                            *We* don't need a solution for the 7.7 line.  We're basing our next release off of the 8.x line.

                             

                            If I understand the implication of making the loading async (using futures), then the VDBs are immediately available and clients could use standard JDBC timeout methods to control how long to wait before the VDB ultimately becomes ready.  That is a nice consequence.

                            • 11. Re: Issue on VDB deployment order
                              rareddy

                              Steve,

                               

                              For local JNDI connections, with every data source there is implicit service gets created in the AS7. Since they are in same JVM,  solution is to place a listener on this service and only grant the connection at that point or timeout.

                               

                              Ramesh..

                              • 12. Re: Issue on VDB deployment order
                                shawkins

                                https://issues.jboss.org/browse/TEIID-2059 was resolved, but only for 8.1.  I'm still not sure if there is a good workaround in 7.7 for bunty, so we may need to open an issue there as well.

                                 

                                Steve