Is there any way to have more than one PostgreSQL slave servers in the same system.

If yes, how come a master detect each server as different slaves from the below query

select * from pg_stat_replication;

will give one row for each slave which are connected to it, with PID, IP-address/client_address, client_port, etc..

If two servers are running in the same machine gives the same IP-address so it is not a unique identifier.

If slave got restarted then both client_port and PID will change so these are also cant be a unique identifier.

So, what is the unique identifier used by Postgres master to identify each slave server uniquely? Or how it is finding its slave servers differently?


The master does not "find" the replicas. The replicas find the master.

The master identifies the replicas by either their slot_name, or their application_name, or not at all, depending on the context.

What are you trying to do?

| improve this answer | |
  • In that case how come master is generating pg_stat_repication view with different slaves uniquely? – manvith Apr 23 '19 at 8:50
  • Active WAL senders are identified by their process id. This isn't much of an identifier, as it is not stable across system (or just WAL sender) restarts. – jjanes Apr 23 '19 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.