damccorm commented on code in PR #34058:
URL: https://github.com/apache/beam/pull/34058#discussion_r1976055385
##########
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:
Yeah, I think you're right that we can shrink the lock. I was worried about
the case where `this.connection` gets set while waiting on the lock, but I
don't think we need to worry about this as long as there's a 1:1 mapping of
DoFn to thread.
I'll update
--
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]