Abacn commented on code in PR #34058:
URL: https://github.com/apache/beam/pull/34058#discussion_r1976050617
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java:
##########
@@ -1634,12 +1637,22 @@ public void setup() throws Exception {
}
private Connection getConnection() throws SQLException {
- Connection connection = this.connection;
- if (connection == null) {
- DataSource validSource = checkStateNotNull(this.dataSource);
- connection = checkStateNotNull(validSource).getConnection();
- this.connection = connection;
+ Connection connection;
+ DataSource validSource = checkStateNotNull(this.dataSource);
+ boolean reportLineage = false;
+ connectionLock.lock();
+ try {
+ connection = this.connection;
Review Comment:
I understand the race happened when creating connections. Is it necessary to
put "connection = this.connection;" inside lock? This causes every
getConnection() go through a lock (though tested it has little performance
effect)
Or is it preferrable to only synchronize "connection =
validSource.getConnection();" ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]