DBAtlas · Database operations atlas

Allocate a lost primary shard as a last resort (allocate_stale_primary)

ElasticsearchCluster/Node

Command

# Which nodes hold copies of the primary (allocation id, store errors):
GET _shard_stores/musteri?status=red
# Last resort: promote a stale copy to primary; data loss is accepted:
POST _cluster/reroute
{
  "commands": [
    {
      "allocate_stale_primary": {
        "index": "musteri",
        "shard": 0,
        "node": "node-2",
        "accept_data_loss": true
      }
    }
  ]
}

What it does

When the node holding the up-to-date primary copy is permanently lost, assigns an older (not in-sync) copy on another node as primary to take the index out of red.

When to use it

Only when the node hosting the primary cannot be recovered and restoring from a snapshot is not an option or would take longer.

Caution

The stale copy does not contain the latest writes; all writes made after that copy are permanently lost. If the lost node returns later, the more recent copy on it is deleted. Consider recovering the node and restoring from snapshot first. allocate_empty_primary creates the shard completely empty and deletes all data in that shard; use it only when no copy remains.

Open in DBAtlas →

Related