Skip to content

Conversation

@zhaohehuhu
Copy link
Contributor

Purpose of the pull request

close #14189

Brief change log

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

If your pull request contain incompatible change, you should also add it to docs/docs/en/guide/upgrede/incompatible.md

@zhaohehuhu
Copy link
Contributor Author

zhaohehuhu commented May 25, 2023

@caishunfeng @SbloodyS plz review

@SbloodyS SbloodyS added improvement make more easy to user or prompt friendly 3.2.0 for 3.2.0 version labels May 25, 2023
@SbloodyS SbloodyS added this to the 3.2.0 milestone May 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2023

Codecov Report

Merging #14190 (1ae81f5) into dev (d6a4e99) will increase coverage by 0.01%.
The diff coverage is 0.00%.

❗ Current head 1ae81f5 differs from pull request most recent head 63ab6d9. Consider uploading reports for the commit 63ab6d9 to get more accurate results

@@             Coverage Diff              @@
##                dev   #14190      +/-   ##
============================================
+ Coverage     38.52%   38.53%   +0.01%     
- Complexity     4575     4579       +4     
============================================
  Files          1260     1260              
  Lines         43804    43821      +17     
  Branches       4834     4833       -1     
============================================
+ Hits          16874    16885      +11     
- Misses        25057    25063       +6     
  Partials       1873     1873              
Impacted Files Coverage Δ
...ugin/datasource/kyuubi/KyuubiDataSourceClient.java 2.63% <0.00%> (-2.14%) ⬇️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zhaohehuhu
Copy link
Contributor Author

@caishunfeng @SbloodyS plz review

@zhaohehuhu
Copy link
Contributor Author

@caishunfeng @SbloodyS Is there anything that need to improve ? Thanks.

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check failed CI.

@zhaohehuhu
Copy link
Contributor Author

Please check failed CI.

looks like the CI failed due to zookeeper connect timeout

@zhaohehuhu zhaohehuhu force-pushed the Improvement-14189 branch 2 times, most recently from 342e80d to 2355b0b Compare July 19, 2023 02:36
Comment on lines 233 to 243
if (DbType.valueOf(sqlParameters.getType()) == KYUUBI) {
log.info("full jdbc url : {}, user : {} begin to build a connection",
DataSourceUtils.getJdbcUrl(DbType.KYUUBI, baseConnectionParam), baseConnectionParam.getUser());
Class.forName(baseConnectionParam.getDriverClassName());
connection = DriverManager.getConnection(baseConnectionParam.getJdbcUrl(),
baseConnectionParam.getUser(), baseConnectionParam.getPassword());
} else {
connection =
DataSourceClientProvider.getInstance().getConnection(DbType.valueOf(sqlParameters.getType()),
baseConnectionParam);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a good approach. If there are new data sources or task types in the future that need to share the same implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. It's not a good way to do it. Can we extract part of code into getConnection method ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

while (connection == null) {
try {
connection = dataSource.getConnection();
connection = driverManagerDataSource.getConnection();
Copy link
Member

@ruanwenjun ruanwenjun Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add max retry times here, this is dangerous code, in fact, it's better to generate a new connection here, rather than use driverManagerDataSource.getConnection();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment on lines +51 to +59
this.driverManagerDataSource =
new DriverManagerDataSource(DataSourceUtils.getJdbcUrl(DbType.KYUUBI, baseConnectionParam),
baseConnectionParam.getUser(), PasswordUtils.decodePassword(baseConnectionParam.getPassword()));
driverManagerDataSource.setDriverClassName(baseConnectionParam.getDriverClassName());
this.jdbcTemplate = new JdbcTemplate(driverManagerDataSource);
log.info("Init {} {} success.", getClass().getName(),
DataSourceUtils.getJdbcUrl(DbType.KYUUBI, baseConnectionParam));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to use DriverManagerDataSource here, we can directly generate new connections.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DriverManagerDataSource should create a new connection each time, so we possibly can stick to that.

@zhaohehuhu zhaohehuhu force-pushed the Improvement-14189 branch 2 times, most recently from e35eb2d to b0606be Compare July 20, 2023 05:12
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@zhaohehuhu zhaohehuhu closed this Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.2.0 for 3.2.0 version backend improvement make more easy to user or prompt friendly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][plugin]decommission connection pool in kyuubi

4 participants