Skip to content

Commit

Permalink
[postgres] close jdbc connection when close replication connection(ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
loserwang1024 committed Aug 23, 2023
1 parent 2f79b24 commit 7adb037
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ public PostgresConnection openJdbcConnection() {
return (PostgresConnection) openJdbcConnection(sourceConfig);
}

public PostgresReplicationConnection openPostgresReplicationConnection() {
public PostgresReplicationConnection openPostgresReplicationConnection(
PostgresConnection jdbcConnection) {
try {
PostgresConnection jdbcConnection =
(PostgresConnection) openJdbcConnection(sourceConfig);
PostgresConnectorConfig pgConnectorConfig = sourceConfig.getDbzConnectorConfig();
TopicSelector<TableId> topicSelector = PostgresTopicSelector.create(pgConnectorConfig);
PostgresConnection.PostgresValueConverterBuilder valueConverterBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ private void createSlotForGlobalStreamSplit() {
return;
}

try {
try (PostgresConnection connection = postgresDialect.openJdbcConnection()) {
PostgresReplicationConnection replicationConnection =
postgresDialect.openPostgresReplicationConnection();
postgresDialect.openPostgresReplicationConnection(connection);
replicationConnection.createReplicationSlot();
replicationConnection.close(false);
} catch (Throwable t) {
Expand Down

0 comments on commit 7adb037

Please sign in to comment.