In Greenplum, a primary segment fails during the nightly load — what happens to the load, to queries and to the cluster?
The coordinator's fault prober marks the primary down and promotes its mirror. Transactions running at that moment roll back, so the load must be re-run. The cluster keeps serving, but unbalanced, until gprecoverseg restores the pair and gprecoverseg -r the roles.
- Expecting a running load or query to survive the failover, instead of planning a re-run
- Leaving the cluster on its promoted mirrors, where one host now carries extra primaries and sets the speed of every query
- Assuming the coordinator's standby takes over by itself the way segment mirrors do
- Why should a nightly load into Greenplum be safe to re-run from the start, and how would you make it so?
- What changes for the cluster when a whole host fails under group mirroring versus spread mirroring?
How it works in Greenplum and its forks Arenadata DB and Greengage DB. Every primary segment has a mirror on another host, and the primary ships its changes to it. The coordinator's fault tolerance service (FTS) probes the segments. When a primary stops answering, it checks that the mirror is up, marks the primary down in gp_segment_configuration and promotes the mirror to primary.
What that means for a pipeline:
- Running work. Transactions in progress at the moment of failure roll back. The nightly
INSERT ... SELECTor external-table load fails and must be started again. So the load has to be idempotent: reload the whole day or swap a partition, never append rows. - Degraded mode. The cluster answers queries, but the segment has no pair any more, and the host with the promoted mirror carries an extra primary. Under group mirroring (the default) a whole-host failure doubles the active primaries on the backing host, and that host sets the time of every query. Spread mirroring scatters a host's mirrors over several hosts, so each gains one segment.
- Recovery. Once the host is fixed,
gprecoversegbrings the failed segment back as a mirror (incrementally by default). The roles stay swapped untilgprecoverseg -rreturns them; rebalancing cancels running queries, so schedule it outside load windows.
-- which segments are down and which have swapped roles
SELECT content, role, preferred_role, mode, status, hostname
FROM gp_segment_configuration
WHERE status = 'd' OR role <> preferred_role
ORDER BY content;If a primary and its mirror both fail, the database is unavailable. Without mirrors, any segment failure stops the system. The coordinator has its own protection, a standby coordinator, but it does not take over by itself: an administrator activates it with gpactivatestandby, and there is no standby again until gpinitstandby creates a new one.