imaffe commented on issue #555: [ISSUE #554 Update druid version and set ConnectionErrorRetryAttempts ] URL: https://github.com/apache/rocketmq-externals/pull/555#issuecomment-611858398 The problem with previous `DruidDataSourceFactory.createDataSource()` method is, it doesn't support two needed parameters: - connectionErrorRetryAttempts - breakAfterAcquireFailure In JdbcSinkTask code, we have a section like: ``` @Override public void start(KeyValue props) { try { ConfigUtil.load(props, this.config); dataSource = DBUtils.initDataSource(config); connection = dataSource.getConnection(); log.info("init data source success"); } catch (Exception e) { log.error("Cannot start Jdbc Sink Task because of configuration error{}", e); } ... ``` Problem with this is `dataSource = DBUtils.initDataSource(config);` throws exception, it will not terminate but will be blocked as the Druid will retry connecting to the databases every 30 seconds, and was not stopped unless the task gets complete. But if we want the task to stop, we have to rely on the ``` @Override public void stop() { try { if (connection != null){ connection.close(); log.info("jdbc sink task connection is closed."); } } catch (Throwable e) { log.warn("sink task stop error while closing connection to {}", "jdbc", e); } } ``` executes successfully. However since the `datasource` was not created properly, the connection seems to be in a half closed state, and blocked the `stop()` somehow. This update will make the `stop()` able to finish by limiting the retry numbers of the Druid datasource.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
