How to config datasource in WSO2 Stream Integrator 7.1.0 to auto reconnect mysql

231 Views Asked by At

I've tried to setup a datasource connect to MySQL in deployment.yaml of WSO2 SI so that I can use it in my Siddhi apps. It worked fine as normal but when I restart MySQL, the datasource can not reconnect to DB so my Siddhi app get following errors.

How can I config datasource so it can auto reconnect after database restart.

Thank you, Luong.

[2020-11-12 19:32:43,627] ERROR {io.siddhi.extension.io.cdc.source.polling.strategies.DefaultPollingStrategy} - Error occurred while processing records in table SweetProductionTable. {mode=polling, app=CDCWithPollingMode, stream=insertSweetProductionStream} java.sql.SQLException: Connection is closed
    at com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection.lambda$getClosedConnection$0(ProxyConnection.java:493)
    at com.sun.proxy.$Proxy73.prepareStatement(Unknown Source)
    at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:315)
    at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
    at io.siddhi.extension.io.cdc.source.polling.strategies.DefaultPollingStrategy.printEvent(DefaultPollingStrategy.java:142)
    at io.siddhi.extension.io.cdc.source.polling.strategies.DefaultPollingStrategy.poll(DefaultPollingStrategy.java:86)
    at io.siddhi.extension.io.cdc.source.polling.CDCPoller.run(CDCPoller.java:202)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
2

There are 2 best solutions below

2
Shanaka Dilan Premarathna On

At the end of the mysql connection URL can you add the following

&autoReconnect=true

For example:

jdbc:mysql://localhost:3306/wso2_api_stat_alt?useSSL=false&ampautoReconnect=true
0
Luong Dang On

This is a bug of siddhi-io-cdc. A Siddhi app with CDC polling mode get errors when the source database restart. These failures caused by the bug in DefaultPollingStrategy class, printEvent(connection) do not verify connection before using it, must getConnection() first.