pg_rewind installes stored procedures at begin and remove them after end of operation.
This makes it impossible to run twice simultaneously.
 
pg_rewind is a useful extension for Pacemaker clusters.
It makes it possible to demote and sync automatically to the new master (when it is promoted), because it needs only few seconds.
Therefore, this feature can be integrated in the psql resource agent.
 
But it is impossible for the resource agent to guarantee only one node will cann pg_rewind at the same time.
Especially when the Postgres resource is in different clusters configured.
One slave (which calls pg_rewind) will remove the stored procedures another slave is accessing.
 
Would it be possible to add a command line switch to pg_rewind, which does not remove the stored procedures at end of operation and check for existance on start ?
Default is to remove at end.
 
In case we use pg_rewind with Pacemaker, it is harmless existing all the time in the database.
And we can integrate a recover feature into Pacemaker for Postgres resources.
 
Rainer