Cross-cluster replication makes the steady state easy. Reversing it, recovering from failures, and noticing when it has quietly stopped are the hard parts.

The proof of concept made the happy path look easy. This post is about the other paths.

Two kinds of failover

In the two-stream design (Part 2), there is no write failover. If a site goes down, the other site keeps writing its own indices. What you lose is whatever the surviving site hadn't pulled yet, so your recovery point equals the replication lag at the moment of failure. When the failed site returns within the soft-delete retention lease, its followers catch up on their own. If it returns after the lease expires, you recreate those followers, which means a full copy.

In a single-writer design (one-way DR), you promote followers so the DR site can take writes. That is where the work is.

Promoting followers: one index at a time

Each follower becomes a regular index in four steps: pause, close, unfollow, open. There is no wildcard. In our proof of concept, a pattern-based unfollow simply wasn't possible.

POST /orders_east_202311/_ccr/pause_follow POST /orders_east_202311/_close POST /orders_east_202311/_ccr/unfollow POST /orders_east_202311/_open 

With about 2,000 indices, that is a script. Ours needed to build the index list dynamically from GET /*/_ccr/info, be safe to rerun if it stopped halfway, and log every step per index.

Failback is the expensive part

When the old primary comes back, it still holds indices with the same names. A follower can't be created where a same-named index exists, so those indices have to be deleted and then followed again from the new primary. That is a remote recovery, which means a full copy. For about 2,000 indices we estimated up to 10 hours. Then you recreate the auto-follow patterns in the new direction.

The consequence: there is no quick rollback. Once you promote DR and it takes writes, the only way back is another full copy. Elastic's one-way DR tutorial follows the same failover and failback model.

Timeline of normal replication, failover by promoting followers, and failback by a full re-copy.

Failures, restarts, and how much you can lose

  • Transient errors, such as a network blip: follower shards retry on their own.
  • Fatal errors: the follower pauses until someone resumes it. It stalls silently unless you are watching.
  • An outage longer than the retention lease: the leader may discard operations the follower never pulled, and the follower can't catch up. Recreate it, which is a full copy.
  • A follower index deleted on the target: auto-follow doesn't recreate it, and in our 7.x tests no error surfaced anywhere obvious. That index simply stopped replicating.
  • A static setting change on the leader: the follower closes, applies it and reopens, so DR reads on that index blip.
  • Site loss: operations not yet pulled are stranded until the site returns. If it never returns, they are gone.

Monitoring a NOC can actually use

Kibana's CCR page is fine for an engineer looking at one cluster. It isn't something a NOC can alert on. We scripted these checks, each producing one number in the monitoring tool with a threshold:

  1. Heartbeat lag per direction. The same pattern from Part 1: a timestamp written at the source and read at the destination.
  2. Follower shard health from _ccr/stats: any fatal_exception, a growing time_since_last_read_millis, and the gap between leader and follower global checkpoints.
  3. Auto-follow errors from the auto-follow stats (recent_auto_follow_errors).
  4. Inventory diff: leader indices that match a pattern compared with follower indices that actually exist. This is what catches deleted followers.
  5. Doc-count difference per index family, with a tolerance for in-flight writes.
  6. Log scraping on the master nodes for auto-follow errors.
  7. A liveness metric for every script, so a dead check alerts instead of looking green.

If you already run Metricbeat, it has a CCR metricset that covers part of this.

A planned switch, in order

  1. Freeze writers: stop data loads and lock the loader accounts at both sites.
  2. Confirm lag is zero with the heartbeat, and that doc counts match.
  3. Promote followers, or in the two-stream design just repoint the applications.
  4. Move saved objects and security state, if they aren't already automated (Part 6).
  5. Re-establish replication in the new direction and confirm heartbeats flow.
  6. Unlock writers and watch lag for the first hour.

Rehearse it on a staging pair first. Our staging switch is where most of these steps came from.

Risks and precautions

  • A paused follower looks healthy on any dashboard that only checks cluster health.
  • A retention lease shorter than your outage turns a catch-up into a full re-copy.
  • Failback is a full copy. Budget the hours and the bandwidth before you need them.
  • There is no wildcard unfollow. Script it, make it rerunnable, and test it.
  • Deleted followers stop replicating silently. Run the inventory diff.

Three replication gauges and a heartbeat line with the words Silence is not health.

Part 7 of 8 in Elasticsearch Replication & DR Field Notes . Previous: Part 6, What CCR Won't Copy. Next: Part 8, When CCR Can't Follow.

Sources