From 08e7ca60724f693dfed6c006d00aa5dac73a2ae6 Mon Sep 17 00:00:00 2001 From: assaad Date: Fri, 27 Sep 2024 19:53:45 +0200 Subject: [PATCH] [source-postgres]: fix getLsn() utils function for read replicas (#45397) Co-authored-by: Marcos Marx --- airbyte-cdk/java/airbyte-cdk/README.md | 1 + .../airbyte-cdk/core/src/main/resources/version.properties | 2 +- .../src/main/kotlin/io/airbyte/cdk/db/PostgresUtils.kt | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/airbyte-cdk/java/airbyte-cdk/README.md b/airbyte-cdk/java/airbyte-cdk/README.md index ba258aeec234..285c353dbd87 100644 --- a/airbyte-cdk/java/airbyte-cdk/README.md +++ b/airbyte-cdk/java/airbyte-cdk/README.md @@ -174,6 +174,7 @@ corresponds to that version. | Version | Date | Pull Request | Subject | |:-----------|:-----------|:------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 0.47.1 | 2024-09-27 | [\#45397](https://github.com/airbytehq/airbyte/pull/45397) | Allow logical replication from Postgres 16 read-replicas| | 0.47.0 | 2024-09-26 | [\#42030](https://github.com/airbytehq/airbyte/pull/42030) | minor refactor | | 0.46.1 | 2024-09-20 | [\#45700](https://github.com/airbytehq/airbyte/pull/45700) | Destinations: Fix bug in parsing jsonschema | | 0.46.0 | 2024-09-18 | [\#45432](https://github.com/airbytehq/airbyte/pull/45432) | upgrade all libraries to latest version | diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties index 42482588ea2e..650298f4f7d4 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties @@ -1 +1 @@ -version=0.47.0 +0.47.1 diff --git a/airbyte-cdk/java/airbyte-cdk/datastore-postgres/src/main/kotlin/io/airbyte/cdk/db/PostgresUtils.kt b/airbyte-cdk/java/airbyte-cdk/datastore-postgres/src/main/kotlin/io/airbyte/cdk/db/PostgresUtils.kt index 8efa3a28082c..1dd2c2875c9d 100644 --- a/airbyte-cdk/java/airbyte-cdk/datastore-postgres/src/main/kotlin/io/airbyte/cdk/db/PostgresUtils.kt +++ b/airbyte-cdk/java/airbyte-cdk/datastore-postgres/src/main/kotlin/io/airbyte/cdk/db/PostgresUtils.kt @@ -18,7 +18,11 @@ object PostgresUtils { val jsonNodes = database.bufferedResultSetQuery( { conn: Connection -> - conn.createStatement().executeQuery("select * from pg_current_wal_lsn()") + conn + .createStatement() + .executeQuery( + "SELECT CASE WHEN pg_is_in_recovery() THEN pg_last_wal_receive_lsn() ELSE pg_current_wal_lsn() END AS pg_current_wal_lsn;" + ) }, { resultSet: ResultSet -> JdbcUtils.defaultSourceOperations.rowToJson(resultSet) } )