DBZ-6353 Use correct SQL codes for other cases

This commit is contained in:
Jiri Pechanec 2023-05-03 11:32:14 +02:00
parent 6ced91fe53
commit ab5d643aa8
3 changed files with 10 additions and 4 deletions

View File

@ -189,6 +189,7 @@ Helong Zhang
Henrik Schnell Henrik Schnell
Henry Cai Henry Cai
Henryk Konsek Henryk Konsek
Hidetomi Umaki
Himanshu Mishra Himanshu Mishra
Hoa Le Hoa Le
Horia Chiorean Horia Chiorean

View File

@ -59,6 +59,8 @@
*/ */
public class PostgresReplicationConnection extends JdbcConnection implements ReplicationConnection { public class PostgresReplicationConnection extends JdbcConnection implements ReplicationConnection {
private static final String SQL_STATE_INSUFFICIENT_PRIVILEGE = "42501";
private static Logger LOGGER = LoggerFactory.getLogger(PostgresReplicationConnection.class); private static Logger LOGGER = LoggerFactory.getLogger(PostgresReplicationConnection.class);
private final String slotName; private final String slotName;
@ -431,11 +433,13 @@ protected void validateSlotIsInExpectedState(WalPositionLocator walPosition) thr
LOGGER.info("Postgres server doesn't support the command pg_replication_slot_advance(). Not seeking to last known offset."); LOGGER.info("Postgres server doesn't support the command pg_replication_slot_advance(). Not seeking to last known offset.");
} }
else if (e.getMessage().matches("ERROR: must be superuser or replication role to use replication slots(.|\\n)*") else if (e.getMessage().matches("ERROR: must be superuser or replication role to use replication slots(.|\\n)*")
|| PSQLState.OBJECT_IN_USE.getState().equals(e.getSQLState())) { || SQL_STATE_INSUFFICIENT_PRIVILEGE.equals(e.getSQLState())) {
LOGGER.warn("Unable to use pg_replication_slot_advance() function. The Postgres server is likely on an old RDS version", e); LOGGER.warn(
"Unable to use pg_replication_slot_advance() function. The Postgres server is likely on an old RDS version or privileges are not correctly set",
e);
} }
else if (e.getMessage().matches("ERROR: cannot advance replication slot to.*") else if (e.getMessage().matches("ERROR: cannot advance replication slot to.*")
|| PSQLState.NOT_IMPLEMENTED.getState().equals(e.getSQLState())) { || PSQLState.OBJECT_NOT_IN_STATE.getState().equals(e.getSQLState())) {
switch (connectorConfig.getEventProcessingFailureHandlingMode()) { switch (connectorConfig.getEventProcessingFailureHandlingMode()) {
case FAIL: case FAIL:
case WARN: case WARN:

View File

@ -205,4 +205,5 @@ brenoavm,Breno Moreira
ddsr-ops,ddsr-ops ddsr-ops,ddsr-ops
subkanthi,Kanthi Subramanian subkanthi,Kanthi Subramanian
benw-at-birdie,Ben White benw-at-birdie,Ben White
miguelbirdie, Miguel Angel Sotomayor miguelbirdie,Miguel Angel Sotomayor
umachi,Hidetomi Umaki