Primary and secondary nodes in a cluster send heartbeats to each other every half second. When a secondary node fails to receive a single heartbeat from the primary node, it will consider the primary node to be off-line or unreachable. This can happen on the primary node due to a network problem or when it is rebooting. When the primary is unreachable, a selection process for a new primary node will be triggered. The selection is promptly performed and decided based on the health of the nodes. When a secondary node is selected, all other secondary nodes will treat it as the new primary node and the failover process will start.
The heartbeat can also fail due to an issue with the secondary node. In that case, the selection process is still triggered but the primary node remains the same.