Skip to content

Commit

Permalink
0005882: Added check for REPLICATION role attribute when setting up a…
Browse files Browse the repository at this point in the history
… log-based Postgres node
  • Loading branch information
evan-miller-jumpmind committed Oct 30, 2023
1 parent b11bcc7 commit f5b4384
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions symmetric-assemble/src/asciidoc/appendix/postgresql.ad
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Edit postgresql.conf and restart Postgres after changing:
wal_level = logical
max_replication_slots = 10

If the SymmetricDS user is not a superuser, the following role attribute needs to be added:

[source, Sql]
----
ALTER USER {SYMMETRICDS USER} REPLICATION
----

Replication of updates and deletes work as expected for tables with a primary key.
For tables without a primary key, the user needs to set the REPLICA IDENTITY on the table to either USING INDEX
to record columns from the named index or FULL to record all columns of the row.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,24 @@ public PermissionResult getDropSymTriggerPermission() {
public PermissionResult getLogMinePermission() {
PermissionResult result = new PermissionResult(PermissionType.LOG_MINE, "UNIMPLEMENTED");
String walLevel = getSqlTemplate().queryForString("select current_setting('wal_level')");
if ("logical".equals(walLevel)) {
boolean hasReplicationPermission = getSqlTemplate().queryForInt(
"select count(*) from pg_roles where (rolsuper or rolreplication) and pg_has_role(current_user, oid, 'member')") > 0;
if ("logical".equals(walLevel) && hasReplicationPermission) {
result.setStatus(Status.PASS);
} else {
result.setStatus(Status.FAIL);
result.setTestDetails(walLevel);
result.setSolution("Set wal_level to logical");
if (!"logical".equals(walLevel)) {
if (!hasReplicationPermission) {
result.setTestDetails("wal_level=" + walLevel + ", missing REPLICATION role attribute");
result.setSolution("Set wal_level to logical and grant the REPLICATION role attribute to the SymmetricDS user");
} else {
result.setTestDetails(walLevel);
result.setSolution("Set wal_level to logical");
}
} else {
result.setTestDetails("Missing REPLICATION role attribute");
result.setSolution("Grant the REPLICATION role attribute to the SymmetricDS user");
}
}
return result;
}
Expand Down

0 comments on commit f5b4384

Please sign in to comment.