diff --git a/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresSnapshotChangeEventSource.java b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresSnapshotChangeEventSource.java index ed247de8cbe..fc0924cf37d 100644 --- a/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresSnapshotChangeEventSource.java +++ b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresSnapshotChangeEventSource.java @@ -293,6 +293,12 @@ protected void setSnapshotTransactionIsolationLevel(boolean isOnDemand) throws S } else { LOGGER.info("Skipping setting snapshot time, snapshot data will not be consistent"); } + + // Regardless of whether consistent snapshot is enabled or not, we need to set the + // transaction isolation level. + String transactionIsolationLevelStatement = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE;"; + LOGGER.info("Setting transaction isolation levels with statement {}", transactionIsolationLevelStatement); + jdbcConnection.executeWithoutCommitting(transactionIsolationLevelStatement); } /**