Junior — Middle
What actions are taken or what happens inside the system if the main Master replica fails?
sobes.tech AI
Answer from AI
If the primary Master replica fails, the system usually undergoes a failover process — automatic or manual switching to one of the Standby replicas, which then becomes the new master.
What happens internally:
- Monitoring detects that the Master is unavailable.
- A suitable replica with up-to-date data is selected.
- The replica is promoted to write mode and becomes the new Master.
- Other replicas are reconfigured to replicate from the new Master.
- Clients are redirected to the new Master to continue operation.
In Go applications, the detection and failover logic is usually implemented either through third-party tools (such as Patroni, Repmgr) or through custom code using health checks and connection management.
It is important that the data is synchronized to prevent data loss or inconsistency.