Failover in Streaming Replication I have one doubt on master to slave replication in streaming replication in postgresql. I confgured ONE Master and One Slave with streaming replication in my system If Master fails slave act as a master then it is fine.

My Question:
1) who will be the master and who will be the slave when master fails? 2) when slave becomes as a master how much time it will take to get it back fail-over matster as slave?

can please give me the correct scenario for this?
Lets call them A (the master) and B (the slave).


  1) who will be the master and who will be the slave when master fails?


When master (A) fails, you'll have only a slave (B) working, trying to connect to its master - which will not be responding. The slave will still be able to accept read but not write requests.

You need to "promote" the slave (B) from its "slave" status to "master", in order to have a database that accepts write requests.


  1b) who will be the master and who will be the slave when master fails - and I promote the slave?


You will have a single master (B), no slave. 


  2) when slave becomes as a master how much time it will take to get it back fail-over master as slave?


You will need to setup a new slave (C) or use the old master (A) as a slave of the new master (B). Use pg_rewind, rsync or pg_basebackup if you want to reuse the old master as a new slave. With pg_rewind or rsync you can be back up and running with a new slave very quickly (seconds possibly, if automated), or within minutes if done manually.