Abacn commented on code in PR #32988:
URL: https://github.com/apache/beam/pull/32988#discussion_r1828116072
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java:
##########
@@ -1575,10 +1629,15 @@ private Connection getConnection() throws SQLException {
public void processElement(ProcessContext context) throws Exception {
// Only acquire the connection if we need to perform a read.
Connection connection = getConnection();
+
// PostgreSQL requires autocommit to be disabled to enable cursor
streaming
// see
https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
- LOG.info("Autocommit has been disabled");
- connection.setAutoCommit(false);
+ // This option is configurable as Informix will error
+ // if calling setAutoCommit on a non-logged database
+ if (disableAutoCommit) {
+ LOG.info("Autocommit has been disabled");
+ connection.setAutoCommit(false);
Review Comment:
It's not recommended to mutate connection here. Connection is cached once
created.
For #31111 one can set "withDataSourceConfiguration" or
"withDataSourceProviderFn" which creates DataSource that disabled autocommit,
no need additional parameters or SDK change here
--
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]