Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-4592

Creation, deletion and recreation of data source fails with exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 9.1, 9.1.1
    • AdminApi
    • None

      Creating a data source, using the Teiid Admin API, deleting it and recreating results in failing to recreate and an exception is generated. I don't know whether teiid is missing a step or wildfly is failing in some way.

      org.teiid.adminapi.AdminProcessingException: TEIID70006 {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "WFLYCTL0158: Operation handler failed: org.jboss.msc.service.DuplicateServiceException: Service org.wildfly.data-source.MySqlDS is already registered"}}
      	at org.teiid.adminapi.jboss.AdminFactory$ResultCallback.onFailure(AdminFactory.java:193)
      	at org.teiid.adminapi.jboss.AdminFactory$AdminImpl.cliCall(AdminFactory.java:1699)
      	at org.teiid.adminapi.jboss.AdminFactory$AdminImpl.createDataSource(AdminFactory.java:572)
      	at org.komodo.teiid.TeiidInstanceImpl.createDataSource(TeiidInstanceImpl.java:238)
      	at org.komodo.plugin.framework.teiid.AbstractTeiidInstance.getOrCreateDataSource(AbstractTeiidInstance.java:575)
      	at org.komodo.teiid.AbstractTestTeiidInstance.deployDataSource(AbstractTestTeiidInstance.java:195)
      	at org.komodo.teiid.AbstractTestTeiidInstance.testDataSourceOperations(AbstractTestTeiidInstance.java:233)
      	at org.komodo.teiid.TestTeiidInstance.testDataSourceOperations(TestTeiidInstance.java:76)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.jboss.arquillian.junit.Arquillian$8$1.invoke(Arquillian.java:374)
      	at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
      	at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
      	at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:53)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
      	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
      	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:130)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
      	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:136)
      	at org.jboss.arquillian.junit.Arquillian$8.evaluate(Arquillian.java:367)
      	at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:245)
      	at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:426)
      	at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
      	at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:259)
      	at org.jboss.arquillian.junit.Arquillian$7$1.invoke(Arquillian.java:319)
      	at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.execute(ClientBeforeAfterLifecycleEventExecuter.java:99)
      	at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.on(ClientBeforeAfterLifecycleEventExecuter.java:72)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
      	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
      	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createBeforeContext(ContainerEventController.java:124)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:130)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
      	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.fireCustomLifecycle(EventTestRunnerAdaptor.java:159)
      	at org.jboss.arquillian.junit.Arquillian$7.evaluate(Arquillian.java:312)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:204)
      	at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:426)
      	at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
      	at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:218)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:166)
      

      Below is the gist of a test demonstrating the steps to reproduce. This should provide a template for repoducing the issue in question. At the core though is teiid's admin.deleteDataSource(name) which is directly called from getTeiidInstance().deleteDataSource(dsName), resulting in some trace being left behind.

          private void wait(int seconds) {
              try {
                  Thread.sleep(seconds * 1000);
              } catch (Exception ex) {
                  // Nothing required
              }
          }
      
          private TeiidDataSource deployDataSource() throws Exception {
              /*
                   <jdbc-connection name="MySqlPool">
                      <jndi-name>java:/MySqlDS</jndi-name>
                      <driver-name>mysql-connector-java-5.1.39-bin.jarcom.mysql.jdbc.Driver_5_1</driver-name>
                      <property name="track-statements">NOWARN</property>
                      <property name="connection-url">jdbc:mysql://db4free.net:3306/usstates</property>
                      <property name="share-prepared-statements">false</property>
                      <property name="statistics-enabled">false</property>
                      <property name="validate-on-match">false</property>
                      <property name="allow-multiple-users">false</property>
                      <property name="user-name">komodo</property>
                      <property name="password">XUMz4vBKuA2v</property>
                      <property name="use-fast-fail">false</property>
                      <property name="set-tx-query-timeout">false</property>
                      <property name="spy">false</property>
                  </jdbc-connection>
               */
          
              String displayName = "MySqlPool";
              String jndiName = "java:/MySqlDS";
              String typeName = "mysql-connector_com.mysql.jdbc.Driver_5_1";
              Properties properties = new Properties();
              properties.setProperty("password", "XUMz4vBKuA2v");
              properties.setProperty("user-name", "komodo");
              properties.setProperty("validate-on-match", "false");
              properties.setProperty("connection-url", "jdbc:mysql://db4free.net:3306/usstates");
              properties.setProperty("jndi-name", "java:/MySqlDS");
              properties.setProperty("driver-name", "mysql-connector-java-5.1.39-bin.jar_com.mysql.jdbc.Driver_5_1");
          
              TeiidDataSource teiidDataSource = getTeiidInstance().getOrCreateDataSource(displayName, jndiName, typeName, properties);
              assertNotNull(teiidDataSource);
              return teiidDataSource;
          }
      
          @Test
          public void testDataSourceOperations() throws Exception {
              getTeiidInstance().connect();
              assertTrue(getTeiidInstance().isConnected());
      
              //
              // Load the sql driver ready for deployment to make the data source valid
              //
              String MYSQL_DRIVER = "mysql-connector";
              InputStream driverStream = TestUtilities.mySqlDriver();
              assertNotNull(driverStream);
              File driverFile = TestUtilities.createTempFile(MYSQL_DRIVER, ".jar");
              driverFile.deleteOnExit();
              FileUtils.write(driverStream, driverFile);
      
              //
              // Deploy the mysql driver
              //
              getTeiidInstance().deployDriver(MYSQL_DRIVER, driverFile);
      
              //
              // Give the driver time to be deployed
              //
              wait(2);
      
              //
              // Deploy the data source
              //
              TeiidDataSource teiidDataSource = deployDataSource();
      
              //
              // Test the data source exists
              //
              assertTrue(getTeiidInstance().dataSourceExists(teiidDataSource.getName()));
      
              //
              // Delete the data source
              //
              String dsName = teiidDataSource.getName();
              getTeiidInstance().deleteDataSource(dsName);
      
              //
              // Give the data source time to be removed
              //
              wait(4);
      
              //
              // Refresh the teiid connection
              //
              getTeiidInstance().reconnect();
      
              //
              // Test the data source no longer exists, which it should not
              //
              assertFalse(getTeiidInstance().dataSourceExists(dsName));
      
              /*
               * Try redeploying
               */
              try {
                  //
                  // This will throw an exception since something has remained of the data source
                  //
                  teiidDataSource = deployDataSource();
                  wait(4);
                  getTeiidInstance().reconnect();
      
                  assertTrue(getTeiidInstance().dataSourceExists(dsName));
              } catch(Exception ex) {
                  throw ex;
              } finally {
                  if (getTeiidInstance().dataSourceExists(dsName)) {
                      // Ensure everything tidied up at the end
                      getTeiidInstance().deleteDataSource(dsName);
                      wait(4);
                  }
              }
          }
      

              rhn-engineering-shawkins Steven Hawkins
              parichar@redhat.com Paul Richardson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: