Open Zhaoxun opened 1 year ago
BTW , I tested pure pg_rewind with noreplication role rep and it worked:
pg_rewind -D '/pgdata' --source-server='host=172.17.1.2 port=5432 user=rep dbname=postgres connect_timeout=5'
pg_rewind: servers diverged at WAL location 0/81C4E60 on timeline 1
pg_rewind: rewinding from last common checkpoint at 0/81C4DE8 on timeline 1
pg_rewind: Done!
So for sheer pg_rewind it does not need a replication role, and on the contrary, it needs a noreplication role. But repmgr node rejoin requires to execute pg_rewind as well as using a replication role! Thus it would fail no matter the role is replication or noreplication!
Altering the user from replication to noreplication doesn't fix the problem of missing execution permissions. The easy way is to make rep a superuser.
First I create role 'rep' for repmgr to use like these:
So 'rep' is the least privileged user according to repmgr's official document and postgresql's pg_rewind documentation.
However, after encountering the strange error occurred on both pg15 and pg16 like these:
https://serverfault.com/questions/1144242/
I re-checked the documentation for pg_rewind again, and found a line:
-source-server=connstr Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role.
So I guess it is the 'replication role' that caused the issue, thus
ALTER ROLE rep NOREPLICATION;
But now the rewind encounters another problem - it won't process unless it is a replication role!
So either way it does not work! repmgr =the latest version 5.4dev on both pg15 and pg16!