siddhi-io / distribution

Siddhi streaming runtime and tooling distribution
http://siddhi.io
Apache License 2.0
24 stars 26 forks source link

Tooling fails to start when mysql server is down #551

Closed malinthar closed 5 years ago

malinthar commented 5 years ago

Description: I have few siddhi files which use rdms:cud and rdbms:query operations in the workspace folder. When I tried to start the editor when the mysql server is down,tooling fails to start.Following is the stack trace printed

tooling.bat
"C:\Users\wso2\DOCUME~1\siddhi\SIDDHI~1.0-S\bin\..\bin\version.txt"
Oct 03, 2019 10:56:47 PM org.wso2.carbon.tools.InstallJarsTool execute
WARNING: The jars location:jars and/or bundle location:bundles and/or lib location:lib  does not have appropriate read/write permissions.
JAVA_HOME environment variable is set to C:\Program Files\Java\jdk1.8.0_221
CARBON_HOME environment variable is set to C:\Users\wso2\DOCUME~1\siddhi\SIDDHI~1.0-S\bin\..
RUNTIME_HOME environment variable is set to C:\Users\wso2\DOCUME~1\siddhi\SIDDHI~1.0-S\wso2\tooling\bin\..
RUNTIME environment variable is set to tooling
osgi> [2019-10-03 22:56:53,492]  INFO {org.wso2.msf4j.internal.websocket.EndpointsRegistryImpl} - Endpoint Registered : /console
[2019-10-03 22:56:55,056]  INFO {org.wso2.msf4j.internal.websocket.WebSocketServerSC} - All required capabilities are available of WebSocket service component is available.
[2019-10-03 22:56:55,868]  INFO {org.wso2.carbon.metrics.core.config.model.JmxReporterConfig} - Creating JMX reporter for Metrics with domain 'org.wso2.carbon.metrics'
[2019-10-03 22:56:55,911]  INFO {org.wso2.msf4j.analytics.metrics.MetricsComponent} - Metrics Component is activated
[2019-10-03 22:56:55,923]  INFO {org.wso2.carbon.databridge.agent.internal.DataAgentDS} - Successfully deployed Agent Server
[2019-10-03 22:56:56,143]  INFO {io.siddhi.distribution.editor.core.internal.WorkspaceDeployer} - Workspace artifact deployer initiated.
[2019-10-03 22:56:56,209]  INFO {io.siddhi.distribution.event.simulator.core.service.CSVFileDeployer} - CSV file deployer initiated.
[2019-10-03 22:56:56,225]  INFO {io.siddhi.distribution.event.simulator.core.service.SimulationConfigDeployer} - Simulation config deployer initiated.
[2019-10-03 22:56:58,297] ERROR {com.zaxxer.hikari.pool.HikariPool} - HikariPool-1 - Exception during pool initialization. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2186)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353)
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562)
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
        at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
        at org.wso2.carbon.datasource.rdbms.hikari.HikariRDBMSDataSource.getDataSource(HikariRDBMSDataSource.java:61)
        at org.wso2.carbon.datasource.rdbms.hikari.HikariDataSourceReader.createDataSource(HikariDataSourceReader.java:74)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildDataSourceObject(DataSourceBuilder.java:79)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildDataSourceObject(DataSourceBuilder.java:60)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildCarbonDataSource(DataSourceBuilder.java:44)
        at org.wso2.carbon.datasource.core.DataSourceManager.initDataSources(DataSourceManager.java:163)
        at org.wso2.carbon.datasource.core.internal.DataSourceListenerComponent.onAllRequiredCapabilitiesAvailable(DataSourceListenerComponent.java:125)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager.lambda$notifySatisfiableComponents$7(StartupComponentManager.java:266)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager.notifySatisfiableComponents(StartupComponentManager.java:252)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupOrderResolver$1.run(StartupOrderResolver.java:204)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
        ... 32 more

[2019-10-03 22:56:58,380] ERROR {org.wso2.carbon.datasource.rdbms.hikari.HikariRDBMSDataSource} - Cannot connect to JDBC URL jdbc:mysql://localhost:3306/Customers?useSSL=false. Failed due to Failed to initialize pool: Communications link failure

I had configured the {Distribution_Home}/conf/deployment.yaml file to add the DataSource as following.

  # Datasource Configurations
dataSources:
  - name: Customers
    description: The datasource used for registry and user manager
    definition:
      type: RDBMS
      configuration:
        jdbcUrl: 'jdbc:mysql://localhost:3306/Customers?useSSL=false'
        username: testuser
        password: test
        driverClassName: com.mysql.jdbc.Driver
        maxPoolSize: 10
        idleTimeout: 60000
        connectionTestQuery: SELECT 1
        validationTimeout: 30000
        isAutoCommit: false

    #Authentication Configurations: Authentication is disabled in editor profile
authentication:
  restAPIAuthConfigs:
    authEnable: false

extensions:
      - extension:
          name: query
          namespace: rdbms
          properties:
            perform.CUD.operations: true

When the Customers dataSource configuration is removed, editor started to work properly.

Affected Product Version: v5.1.0-RC1 OS, DB, other environment details and versions:
OS-Windows Steps to reproduce: Deploy a siddhi file which uses rdbms:cud or rdbms:query operations

niveathika commented 5 years ago

@Malintha1996 This is the expected behaviour since we expect a healthy database connection for the server to start. We will recover if the database goes down and starts during the run time. However, it should be healthy when the server starts. This is mandatory for databases needed for server functioning such as persistence db, permission db etc.

In your case, since this is a database used for testing in the siddhi app and you want to initialise even if the database cannot be connected you can set initializationFailTimeout=-1 for this specific data source only. Please not, this database needs to be active when you start the siddhi app.

  # Datasource Configurations
dataSources:
  - name: Customers
    description: The datasource used for registry and user manager
    definition:
      type: RDBMS
      configuration:
        jdbcUrl: 'jdbc:mysql://localhost:3306/Customers?useSSL=false'
        username: testuser
        password: test
        driverClassName: com.mysql.jdbc.Driver
        maxPoolSize: 10
        idleTimeout: 60000
        connectionTestQuery: SELECT 1
        validationTimeout: 30000
        isAutoCommit: false
        initializationFailTimeout: -1
malinthar commented 5 years ago

ack with thanks.

On Thu, Nov 14, 2019 at 3:43 PM Niveathika notifications@github.com wrote:

Closed #551 https://github.com/siddhi-io/distribution/issues/551.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/siddhi-io/distribution/issues/551?email_source=notifications&email_token=AIMURVMOCXVIIO4H5VPTJS3QTUQGNA5CNFSM4I5GJAKKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOU3GTN3I#event-2798466797, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMURVK43ZTT4NXXKIN3B7DQTUQGNANCNFSM4I5GJAKA .

-- Best Regards Malintha Ranasinghe Undergraduate Department of Computer Science & Engineering University of Moratuwa. mobile:0769377196