Trash

List the cluster trash

/ Trash, / List

List the cluster trash #

List every node’s trash, merged into one cluster-wide, namespace-centric view. The request may be sent to any node; the node that receives it aggregates the trash of every cluster member.

Examples #

GET /_cluster/trash

A typical item — here a deleted namespace held on two nodes:

{
  "nodes_scanned": 2,
  "unreachable_nodes": [],
  "retention_secs": 86400,
  "items": [
    {
      "name": "1788916375_namespace-website",
      "deleted_at": 1788916375,
      "bytes": 2097152,
      "files": 42,
      "kind": "namespace",
      "namespace": "website",
      "collections": 3,
      "shard_groups": 12,
      "shard_copies": 14,
      "restorable": true,
      "holders": [
        { "node_id": "…", "node_name": "pizza-1", "bytes": 1048576, "files": 21 },
        { "node_id": "…", "node_name": "pizza-2", "bytes": 1048576, "files": 21 }
      ]
    }
  ]
}

Request #

GET /_cluster/trash

Response #

  • items — newest first; each item merges every node that still holds a copy of the data into holders.
  • kind — namespace or collection, parsed from the delete-time snapshot. Items without a snapshot (legacy items swept by the orphan scanner before snapshots existed, or a failed snapshot write) report restorable: false and cannot be restored.
  • retention_secs — the effective retention; items are physically deleted once older than this.
  • unreachable_nodes — members that could not be reached; the list may be incomplete for items they hold.

Verify a trash item

/ Trash, / Verify

Verify a trash item #

Run a read-only shard-completeness check on a trash item, across every node that still holds its data. Nothing is moved or written — this is the preflight for a restore.

Examples #

POST /_cluster/trash/1788916375_namespace-website/verify

With ?deep=true, every present segment file additionally has its footer parsed — truncated or corrupted files are reported by name. Deep mode can take noticeably longer on large items.

{
  "item": "1788916375_namespace-website",
  "deep": false,
  "kind": "namespace",
  "namespace": "website",
  "restorable": true,
  "degraded": false,
  "shard_groups": [
    {
      "collection": "website:logs",
      "shard": "a1b2…",
      "expected_copies": 2,
      "complete_copies": 2,
      "copies": [
        { "node": "…", "node_name": "pizza-1", "primary": true, "complete": true },
        { "node": "…", "node_name": "pizza-2", "primary": false, "complete": true }
      ]
    }
  ],
  "issues": [],
  "unreachable_nodes": []
}

Request #

POST /_cluster/trash/<item>/verify[?deep=true]

Path parameters #

Response #

  • restorable — true when every shard group with recorded data has at least one complete copy on some node. A shard group counts a copy as complete when its allocation directory AND its segment manifest with all declared local files are present (and, in deep mode, every file’s footer parses).
  • degraded — true when the item is restorable but some recorded copies are missing; the restore comes back with fewer replicas, which the allocator backfills.
  • issues — human-readable problem lines (missing directories, missing/corrupt segment files, unreachable nodes), each prefixed with the node it applies to.

Restore a trash item

/ Trash, / Restore

Restore a trash item #

Restore a trashed collection — or a whole deleted namespace — back into the cluster, cluster-coordinated: every holder node moves its copy of the data back, the metadata is re-registered through Raft with the ORIGINAL collection/rolling/shard UUIDs, and the recorded shard placements are replayed so every engine re-opens its original working directory with all documents.

Examples #

Restore a deleted namespace under a new name (every collection comes back inside it):

...

Delete a trash item everywhere

/ Trash, / Delete

Delete a trash item everywhere #

Physically delete one trash item on every node that still holds it, without waiting for the retention window. This cannot be undone.

Examples #

POST /_cluster/trash/1788916375_namespace-website/delete
{ "deleted": true, "item": "1788916375_namespace-website", "nodes": 2 }

Request #

POST /_cluster/trash/<item>/delete

Path parameters #

Empty the trash everywhere

/ Trash, / Delete

Empty the trash everywhere #

Physically delete every trashed item on every node, without waiting for the retention window. This cannot be undone.

Examples #

POST /_cluster/trash/empty
{ "nodes": 2, "removed": 5 }

Request #

POST /_cluster/trash/empty

Cluster-wide recycle bin

/ Trash, / Restore, / Operations

Cluster-wide recycle bin #

Accidental deletes used to be a race against the sweeper: deleting a namespace only dropped metadata, and the data directories drifted into the trash WITHOUT a recovery snapshot — permanently unrestorable. The recycle bin is now a first-class, cluster-wide surface with a namespace-centric view, a pre-restore integrity check, and one-request restore:

# One cluster-wide list — every node's trash merged by item, grouped by
# namespace, with the delete-time snapshot summary of each item.
GET /_cluster/trash

Deleting a namespace captures a restore snapshot for every collection it contains, so the WHOLE namespace comes back as a unit — original schemas, shard UUIDs, partition routing and placements included:

...

Trash APIs

/ Trash, / Restore, / Operations

Trash APIs #

The trash (recycle bin) is node-local filesystem state — deleted namespaces and collections are moved into <data_path>/trash/ and physically deleted only after trash.retention_secs elapses. These cluster-level APIs aggregate every node’s trash on the server side and give you one namespace-centric view, a read-only shard-completeness verification, and cluster-wide restore/purge:

Deleting a namespace (DELETE /_namespace/<name>) now moves the whole namespace — every collection, with a restore snapshot per collection — into the trash as a single item; restoring it brings back all collections with their original schemas, shard UUIDs and placements. Deleting a collection keeps the per-collection behavior it always had.

...