Menu

How to detect PostgreSQL split-brain with two commands (and what actually prevents it)
📰

How to detect PostgreSQL split-brain with two commands (and what actually prevents it)

DEV Community: postgres·Diego Gil Serrano·4 days ago
#SM9VOtFF
#devtopostgresql#devto#dev#node#primary
Reading 0:00
15s threshold

Split-brain is the PostgreSQL high-availability failure that nobody notices until it is too late: two nodes accept writes at the same time, applications write different data to each one, and there is no clean way to merge them afterwards.

The good news is that detecting it takes two commands, and preventing it comes down to three design rules.

Detect it: two commands

Run this on every node of the cluster:

SELECT inet_server_addr (), pg_is_in_recovery (), timeline_id FROM pg_control_checkpoint ();

Enter fullscreen mode

Exit fullscreen mode

pg_is_in_recovery() = f means the node thinks it is a primary.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.