[
https://issues.apache.org/jira/browse/BEAM-12044?focusedWorklogId=572003&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-572003
]
ASF GitHub Bot logged work on BEAM-12044:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 25/Mar/21 16:59
Start Date: 25/Mar/21 16:59
Worklog Time Spent: 10m
Work Description: jkff commented on a change in pull request #14338:
URL: https://github.com/apache/beam/pull/14338#discussion_r601675706
##########
File path:
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
##########
@@ -903,6 +903,8 @@ public void processElement(ProcessContext context) throws
Exception {
if (connection == null) {
connection = dataSource.getConnection();
}
+ // PostgreSQL requires autocommit to be disabled to enable cursor
streaming
Review comment:
In the source code. If someone wonders why this is here and why Postgres
requires this (and whether other DBs might also require it for the same
reason), it's better if they can see it right there in the code rather than
have to dig into Git history.
I would perhaps propose the following phrasing:
```
Some databases require autocommit to be disabled to enable cursor streaming.
E.g. PostgreSQL:
https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
```
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 572003)
Time Spent: 40m (was: 0.5h)
> JdbcIO should explicitly setAutoCommit to false
> -----------------------------------------------
>
> Key: BEAM-12044
> URL: https://issues.apache.org/jira/browse/BEAM-12044
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Affects Versions: 2.28.0
> Reporter: Sylvain Veyrié
> Priority: P2
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Hello,
> Per [PostgreSQL JDBC
> documentation|https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor],
> autocommit must be explicitly disabled on the connection to allow cursor
> streaming.
> [~jkff] mentionned it [on the mailing
> list|https://www.mail-archive.com/[email protected]/msg16808.html], however
> even if there is:
> {code:java}
> poolableConnectionFactory.setDefaultAutoCommit(false);
> {code}
> in JdbcIO:1555, currently, at least with JDBC driver 42.2.16, any read with
> JdbcIO will memoize the whole dataset (which leads to OOM), since
> {code:java}
> connection.getAutoCommit()
> {code}
> returns true in JdbcIO#ReadFn#processElement.
> I can provide a PR — the patch is pretty simple (and solves the problem for
> us in 2.28.0):
> {code:java}
> if (connection == null) {
> connection = dataSource.getConnection();
> }
> connection.setAutoCommit(false); // line added
> {code}
> Thanks!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)