Skip to content

Lesson 9 of 9 · 29m

Index Lifecycle, Snapshots, Upgrades, and Failure Response

Operate retention, rollover, snapshots, restores, rolling upgrades, and incident response as rehearsed procedures rather than hopeful console clicking.

The most dangerous search cluster is not the one with no automation. It is the one with automation nobody has ever restored from. Index lifecycle policies, snapshots, and rolling upgrades are straightforward when rehearsed and brutal when improvised during an incident. Production maturity is measured by whether the recovery path is boring.

Lifecycle policy is a data contract

For time-series data, define rollover, phase transitions, deletion, and replica behavior explicitly:

{
  "policy": {
    "phases": {
      "hot": {"actions": {"rollover": {"max_primary_shard_size": "30gb", "max_age": "7d"}}},
      "warm": {"min_age": "2d", "actions": {
        "allocate": {"number_of_replicas": 0},
        "forcemerge": {"max_num_segments": 1}
      }},
      "delete": {"min_age": "30d", "actions": {"delete": {}}}
    }
  }
}

Exact action availability varies between Elasticsearch and OpenSearch versions, but the design principle survives: write-hot indexes, optimize after writes stop, reduce cost as data ages, and delete by index boundary.

Snapshots are restore systems

Register a repository, test connectivity, snapshot with retention, and restore into an isolated namespace or alternate index name:

curl -X PUT 'http://localhost:9200/_snapshot/s3_repository'   -H 'content-type: application/json' -d '{
    "type": "s3",
    "settings": {
      "bucket": "search-prod-snapshots",
      "base_path": "cluster-a",
      "readonly": false
    }
  }'

A successful state: SUCCESS snapshot is not proof that restoration works. Test restore time, version compatibility, index settings conflicts, security configuration, and application behavior. Measure whether recovery time objective is minutes, hours, or fantasy.

Rolling upgrades depend on shard discipline

A normal rolling upgrade sequence is conceptually:

1. verify cluster health and snapshot status
2. disable shard allocation if required by the upgrade procedure
3. stop/upgrade/start one node
4. wait for cluster membership and shard recovery
5. repeat node by node
6. re-enable allocation and verify health

Never improvise around version-specific instructions. Mixed-version clusters are tolerated for rolling upgrades within documented compatibility windows, not as a permanent architecture. Read breaking changes for mappings, security, snapshot formats, index compatibility, and deprecated settings.

Failure response starts before the failure

Write down the first ten commands before you need them:

curl -s 'http://localhost:9200/_cluster/health?pretty'
curl -s 'http://localhost:9200/_cat/nodes?v'
curl -s 'http://localhost:9200/_cat/shards?v' | head
curl -s 'http://localhost:9200/_cluster/allocation/explain?pretty' -d '{}'
curl -s 'http://localhost:9200/_tasks?detailed&pretty'
curl -s 'http://localhost:9200/_nodes/stats/indices,fs,jvm,thread_pool?pretty'

Pair cluster evidence with host evidence: disk usage, iostat, service logs, kernel messages, container events, network partitions, and cloud volume health. Search nodes often report symptoms created elsewhere.

Know the ugly failure modes

Split-brain behavior is largely prevented by modern quorum-based master election, but misconfigured discovery seed lists, minimum master nodes in legacy versions, or partitioned networks still create outages. Corrupted shards may require restore from snapshot or, in narrow cases, allocation of a stale copy after understanding data loss. Full disks can block writes cluster-wide. Mapping explosions can make cluster state too large to recover quickly. These are architecture and operations failures, not merely bad luck.

Field notes

  • Test restores on a schedule. A snapshot repository no one can read during an incident is an expensive archive of false confidence.
  • Prefer index-level deletion over delete-by-query for retention; it is cheaper and operationally cleaner.
  • Record actual shard count, heap, disk, indexing rate, search rate, and growth monthly. Capacity surprises are usually visible weeks in advance.
  • During incidents, stop nonessential dashboard refreshes and bulk jobs before starting expensive cluster-wide recovery operations.

Was this lesson helpful?

Sign in to rate