Home / Market / iceberg snapshot maintenance review

iceberg snapshot maintenance review

Run read-only Apache Iceberg snapshot-retention and rollback-window reviews from table metadata across branches, tags, parent lineage, and ref expiry rules.

skill★ 509150 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: iceberg-snapshot-maintenance-review description: "Run read-only Apache Iceberg snapshot-retention and rollback-window reviews from table metadata across branches, tags, parent lineage, and ref expiry rules." category: data risk: safe source: self source_type: self date_added: "2026-12-01" author: Koushik-Katkam tags: [apache-iceberg, snapshot-retention, lakehouse, metadata-audit, governance]

---

Iceberg Snapshot Maintenance Review

Overview

Perform a strictly read-only assessment of Apache Iceberg snapshot retention, reference expiry (branches and tags), parent snapshot ancestry, and rollback windows from supplied Iceberg table metadata (metadata.json). Helps data engineers explain why snapshots remain retained (abandoned branches or infinite tags) or detect when aggressive expiration narrows rollback/time-travel windows before running engine maintenance.

Distinction from existing skills:

This skill evaluates supplied metadata only and never executes snapshot expiration, orphan-file deletion, or catalog writes.

When to Use

Prerequisites

How It Works

1. Validate every snapshot entry, ref, and retention property strictly

  1. Validate every entry in snapshots[] (not only traversed snapshots) and assessment inputs: verify as_of_ms and window_ms are non-negative non-boolean integers (failing closed before timestamp arithmetic), format-version is 1, 2, or 3 (strict integer), each snapshot-id is a non-boolean integer without duplicates, timestamp-ms is a present valid integer <= as_of_ms, and optional parent-snapshot-id is an integer.
  2. Read table-level retention properties from properties, applying specification defaults only when absent:
  1. Inspect current-snapshot-id and refs:

2. Evaluate per-reference protection vs. contiguous surviving ancestry

Apply the retention rules documented in retention spec semantics:

  1. Reference type & expiry (max-ref-age-ms): Validate type in {"branch", "tag"} (and "main" is always a "branch") before evaluating expiry so malformed refs cannot pass as expired. main never expires regardless of max-ref-age-ms. Non-main refs expire only when snapshot age strictly exceeds max-ref-age-ms (age > max_ref_age_ms).
  2. Per-reference retention reasons:
  1. Union & contiguous surviving main ancestry: Take the union of snapshots protected by all active branches and tags (retained_snapshots). Compute surviving_main_ancestry by walking main's parent chain from its head and stopping before the first ancestor not in the retained union — so an older main parent kept alive by an active tag or diverging branch remains included. surviving_main_ancestry models contiguous retained lineage in snapshots[] only, not guaranteed timestamp-based time travel (AS OF TIMESTAMP), which also depends on snapshot-log history and physical data/manifest file availability.

See snapshot retention harness for the runnable pytest / CLI reference analyzer and synthetic fixtures.

3. Separate spec estimates from engine behavior

Report results in three distinct sections:

  1. Spec-derived retention estimate: Explicit effective_settings origins, active/expired refs, retained_snapshots per-ref reasons, surviving_main_ancestry + rollback floor, and expirable_snapshots (or None when indeterminate).
  2. Incomplete / invalid metadata warnings: Duplicate or malformed IDs, missing/invalid timestamp-ms, malformed retention settings, broken/cyclic parent chains, or partial refs missing main.
  3. Engine-specific caveats (must not be inferred from metadata.json alone): Explicit runtime overrides (older_than, retain_last, Trino retention_threshold), gc.enabled=false (where reference Iceberg implementations reject expire_snapshots altogether rather than deleting metadata safely), manifest/data-file overlap across snapshots, and catalog commit locks. Retention metadata alone does not establish exact byte savings or safe file deletion.

Examples

Run the read-only retention analyzer in snapshot retention harness:

User request: "Why does main snapshot 1 still survive with our tag, and is our 7-day rollback window intact?"
Inputs: Exported Iceberg metadata.json + target assessment timestamp (read-only).
Expected result: Analyzer tracks per-reference protection separately from the retained union, reports
  surviving_main_ancestry as [2, 1] when active tag 'audit-q1' protects parent 1 past main's max age,
  withholds expirable_snapshots (None) when any snapshot entry lacks timestamp-ms or parent ancestry is
  broken/cyclic, and notes that gc.enabled=false blocks snapshot expiration in reference engines.

Limitations

Safety and Side Effects

Sources and related skills