You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/04/07 11:23:00 UTC

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

     [ https://issues.apache.org/jira/browse/FLINK-39403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated FLINK-39403:
-----------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Priority: Major
>              Labels: pull-request-available
>         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)