You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Levani Kokhreidze (Jira)" <ji...@apache.org> on 2026/04/06 13:54:00 UTC

[jira] [Created] (FLINK-39403) Postgres snapshotting phase might cause transaction leak

Levani Kokhreidze created FLINK-39403:
-----------------------------------------

             Summary: Postgres snapshotting phase might cause transaction leak
                 Key: FLINK-39403
                 URL: https://issues.apache.org/jira/browse/FLINK-39403
             Project: Flink
          Issue Type: Bug
          Components: Flink CDC
            Reporter: Levani Kokhreidze
         Attachments: Screenshot 2026-04-03 at 14.07.58.png

We observe increase in "idle in transaction" times when using Flink CDC (3.4.0 version) with Postgres database. One possible cause might be

 
{code:java}
PostgresSnapshotSplitReadTask ->
PostgresQueryUtils.readTableSplitDataStatement -> 
PostgresQueryUtils.initStatement

{code}
initStatement in return disables auto commit for the connection due to setting the fetchSize on the statement:
{code:java}
private static PreparedStatement initStatement(JdbcConnection jdbc, String sql, int fetchSize)
        throws SQLException {
    final Connection connection = jdbc.connection();
    connection.setAutoCommit(false);
    final PreparedStatement statement = connection.prepareStatement(sql);
    statement.setFetchSize(fetchSize);
    return statement;
} {code}
There's no explicit commit/rollback calls which might cause the transaction leak.

Attached screenshot shows one of the replica databases showing increase in the idle in transaction metric. Table in question had evenly split chunks and there was no other process connecting to that database but Flink CDC.

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)