Tuning CCR checkpoint retention to avoid remote resync
When a Cross-Cluster Replication (CCR) follower briefly disconnects, whether it resumes from where it left off or re-copies the entire index across the link is decided by one thing: whether the leader still retains the operations the follower last acknowledged. This procedure sizes leader soft-deletes and translog retention so a short partition costs an incremental catch-up, not a full remote bootstrap.
Prerequisites
Confirm these before tuning — retention that is too small silently degrades to a resync, and retention that is too large wastes leader disk on operations no follower will ever request.
How retention decides resume versus resync
CCR is a translog-following mechanism: the follower pulls operations from the leader starting at the checkpoint sequence number it last acknowledged. The leader can only serve an operation that still exists — soft-deletes and translog retention are what keep historical operations alive past the point they would normally be merged away. If the follower reconnects while its last checkpoint is still retained, replication resumes from that sequence number. If the checkpoint has aged out, CCR has no incremental starting point and falls back to a full remote bootstrap, re-streaming every segment.
The retention you must keep is the number of operations that can accumulate during the longest partition you want to survive. With a peak write rate in operations per second and a target partition window in seconds, the minimum operation count to retain is:
where is a safety margin (typically –) covering burst above the measured peak. Retention is configured as a byte budget, so convert with the mean operation size in bytes:
The incremental resume path holds only while the follower’s disconnection stays inside the retained window. Expressed as lag, if the follower is behind by operations when it reconnects, resume succeeds precisely when ; beyond that boundary the operations it needs are gone and a resync is unavoidable.
The crossing point is the maximum partition you can survive on the current budget — the single number this whole exercise produces. Sizing retention is the recovery-cost half of the fencing discipline in Preventing split-brain during CCR network partitions; a clean fenced failover is wasted if reconnection then forces a full resync across an already-stressed link.
Step-by-step procedure
1. Measure the peak write rate and mean operation size
Pull indexing throughput and document counts so and are measured, not guessed.
GET logs-000001/_stats/indexing,store
"indexing" : { "index_total" : 41880000, "index_time_in_millis" : 6980000 },
"store" : { "size_in_bytes" : 268435456000 }
# R ≈ index_total / uptime_seconds (ops/s at peak, not average)
# s̄ ≈ size_in_bytes / index_total (mean bytes per operation)
Gotcha: use the peak rate, not the lifetime average from
_stats— a nightly batch load can be ten times the daytime mean, and retention sized to the average resyncs every time the batch window overlaps a partition.
2. Compute the retention byte budget
Apply the formula with your target window and safety margin . For ops/s, s (30 min), , and bytes: ops, so GB.
N_ops = 6000 * 1800 * 1.3 = 14,040,000 ops
S_retain = 14,040,000 * 512 bytes ≈ 7.2 GB
T_max = 14,040,000 / 6000 = 2340 s (39 min headroom incl. margin)
Gotcha: retention is per-shard-aware but you configure a byte budget per index setting; if the index has many primaries, the effective per-shard retention is the budget divided across shards, so size against the busiest shard’s share of , not the index total blindly.
3. Apply retention on the leader index
Set the translog retention byte budget and the soft-deletes retention lease period. Both must be generous enough to cover .
PUT logs-000001/_settings
{
"index.plugins.replication.translog.retention_size": "8gb",
"index.soft_deletes.retention_lease.period": "45m"
}
{ "acknowledged" : true }
Gotcha: round the byte budget up from the computed (7.2 GB → 8 GB here) and set the lease
periodat or above (39 min → 45 min) so the two limits agree; the tighter of the two is what actually bounds recovery, and a mismatched pair silently caps you at the smaller window.
4. Verify the retention lease is held for the follower
A retention lease is the leader’s promise to keep operations for a specific follower. Confirm the lease exists and its retained sequence number trails the follower’s checkpoint.
GET logs-000001/_stats?level=shards&filter_path=**.retention_leases
"retention_leases" : { "leases" : [
{ "id" : "peer_recovery/ccr_follower", "retaining_seq_no" : 90190, "source" : "ccr" }
] }
Gotcha: if
retaining_seq_nois far behind the leader’s current checkpoint, that is healthy — it means the leader is holding history back for the follower. Aretaining_seq_nothat jumps forward to near-current means the lease expired and was renewed from scratch, which is the resync signal.
Verification
Prove that a short disconnect resumes instead of bootstrapping.
# Pause then resume replication to simulate a brief disconnect
POST _plugins/_replication/logs-000001/_pause
POST _plugins/_replication/logs-000001/_resume
GET _plugins/_replication/logs-000001/_status
"status" : "SYNCING" <- resumed incrementally; a full resync would show BOOTSTRAPPING
"syncing_details" : { "leader_checkpoint" : 90512, "follower_checkpoint" : 90480 }
A resume shows SYNCING with a shrinking checkpoint gap and no bootstrap phase. If you see BOOTSTRAPPING, retention aged out during the pause — raise the budget and lease period and retest.
Common failures
| Symptom | Root cause | Fix command |
|---|---|---|
Resume triggers BOOTSTRAPPING |
Retention byte budget smaller than ops accumulated during the gap | PUT logs-000001/_settings {"index.plugins.replication.translog.retention_size":"<larger>"} |
| Lease expired mid-partition | index.soft_deletes.retention_lease.period shorter than the partition |
Raise the period to at least ; one resync re-establishes the lease |
| Leader disk filling from retention | Budget sized to lifetime average with no upper cap during a long follower outage | Lower the budget to a real ; stop replication for a permanently-dead follower to release its lease |
| Per-shard retention too small on a busy shard | Budget divided across many primaries under-serves the hot shard | Recompute against the busiest shard’s share of ; raise the index budget |
| Resume slow but not bootstrapping | Recovery chunk size throttled | PUT logs-000001/_settings {"index.plugins.replication.follower.recovery.chunk_size":"<larger>"} |
Frequently asked questions
What is the cost of setting retention very high to be safe?
Leader disk. Every retained operation is a segment the leader cannot merge away until the follower acknowledges past it or the lease expires. Oversized retention is mostly wasted headroom, and during a long follower outage it can fill the leader’s disk and trip the flood-stage watermark, turning the index read-only. Size to a real maximum partition window rather than an arbitrarily large value, and release the lease by stopping replication for a follower that is never coming back.
Does translog retention or the soft-deletes lease govern the resume window?
Whichever is tighter. Translog retention size bounds the operations kept by byte budget; the soft-deletes retention lease period bounds them by time. CCR needs both to still cover the follower’s last checkpoint, so the effective survivable window is the smaller of the two. Set them as a consistent pair — a byte budget covering thirty minutes paired with a five-minute lease still resyncs after five minutes.
Can I change retention without restarting or re-bootstrapping the index?
Yes. Both index.plugins.replication.translog.retention_size and index.soft_deletes.retention_lease.period are dynamic index settings applied with PUT _settings, and they take effect on the next retention evaluation without a restart. Raising them before a planned maintenance partition is a safe, reversible way to widen the resume window for the duration.
Related
- Preventing split-brain during CCR network partitions — the failover runbook whose recovery step depends on this retention window.
- Split-Brain Prevention — the split-brain model tying retention to safe recovery.
- CCR Setup and Bootstrap — establishing the leader-follower pair whose checkpoints this tuning preserves.