imbajin commented on code in PR #909:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/909#discussion_r4626099963


##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/jdbc/JDBCFetcher.java:
##########
@@ -85,11 +85,15 @@ public void close() {
     @Override
     public  List<Line> nextBatch() throws SQLException {
         if (!start) {
+            // Some drivers (e.g. PostgreSQL) only stream rows through a 
cursor when
+            // auto-commit is off and the fetch size is set before the query 
runs;
+            // otherwise the whole result set is buffered in memory.
+            disableAutoCommit();

Review Comment:
   **⚠️ Avoid opening a long transaction for MySQL reads**
   
   This fetcher is also used for MySQL, so disabling auto-commit here starts a 
transaction for its SELECT that remains open until the reader closes, even when 
Connector/J buffers the result. With InnoDB's REPEATABLE READ and concurrent 
writes, a long load can retain undo history and cause purge lag ([MySQL 
documentation](https://dev.mysql.com/doc/refman/9.7/en/innodb-purge-configuration.html)).
 Could this transaction change be limited to PostgreSQL, or otherwise ended 
promptly for non-streaming drivers? This risk follows from the source and 
documented database behavior; I have not reproduced it on a live MySQL instance.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to