10 Operationalizing Apache Iceberg
Operationalizing an Apache Iceberg lakehouse means turning a working architecture into a reliable production system. The chapter emphasizes that Iceberg’s scalability depends on consistent automation, observability, and policy-driven maintenance. Tasks such as compaction, snapshot expiration, delete file rewriting, and orphan file cleanup should not be handled manually or on rigid schedules alone; they should be orchestrated through tools such as Airflow, dbt, Dagster, or similar workflow systems. By using Iceberg metadata tables to detect small files, snapshot sprawl, delete file growth, and partition imbalance, teams can trigger maintenance only when it is needed and tailor behavior to each table’s ingestion pattern, size, query profile, and compliance requirements.
The chapter also explains how Iceberg’s metadata model supports auditing, governance, retention, and secure deletion. Because every write creates a snapshot, Iceberg provides a built-in change history that can be used to trace data mutations, schema evolution, and file-level changes. Branches and tags help isolate development work, preserve known-good table states, and support reproducible reporting, while catalog systems provide the control plane for access management and audit logging. Retention policies must coordinate snapshot expiration and orphan file cleanup carefully, especially in Merge-on-Read tables where delete files and compaction affect whether deleted data is physically removed. True secure deletion requires a full lifecycle: logical delete, compaction where needed, snapshot expiration, and cleanup, all governed by clear policies and monitored for compliance.
Finally, the chapter presents disaster recovery as a core operational discipline rather than an afterthought. Iceberg’s immutable snapshots, metadata files, time travel, rollback procedures, and table re-registration capabilities provide strong recovery foundations, but they must be paired with catalog backups, object storage versioning, cross-region replication, permission controls, and regular validation drills. Recovery workflows should be automated and tested, including snapshot tagging, catalog export, table re-registration, rollback, metadata integrity checks, and failover procedures. The overall message is that a production Iceberg lakehouse succeeds when maintenance, governance, auditing, and recovery are automated, observable, repeatable, and aligned with business risk and compliance needs.
A Direct Acyclic Graph (DAG) illustrates a non-looping order of tasks. In this example, tasks 2 & 3 can’t begin until task 1 is completed, and task 4 can’t begin until tasks 2 & 3 have been completed. This ensures a task doesn’t begin until all other dependent tasks are complete.
By having conditional logic based on data we can track using the metadata tables, we can avoid running maintenance work when the table doesn’t need it based on metrics like the size of files in the table's current snapshot.
When a record is deleted a new snapshot is created that doesn’t include the deleted data, but the data files still exist. Once all snapshots associated with the files with the deleted data are expired are those data files actually removed from storage.
With object versioning if an object is corrupted or lost you can revert to the previous version of object, the object being a data or metadata file on storage.
FIgure 10.5 You can automate gathering of snapshot metrics when a new snapshot arrives to evaluate it based on your own criteria whether it is a sound restore point, so automated processes can revert to an ideal point if something goes wrong.
Regular backups not just of data files, but of metadata files and catalog state can make disaster recovery and ensure that storage is in sync with the catalog after a recovery scenario.
Summary
- Iceberg lakehouses require more than just design and ingestion planning; operational maturity is key to long-term reliability.
- Orchestration frameworks like Airflow and Dagster help automate compaction, snapshot expiration, and governance across workloads.
- Auditing practices must span both data and metadata, using metadata tables, lineage tools, and catalog logs to track access and change.
- File retention in Iceberg is governed by snapshot expiration and orphan file cleanup, both of which must be configured to match workload patterns.
- Secure deletion in COW and MOR tables depends on snapshot lifecycle management and, in the case of MOR, regular delete file compaction.
- Catalog access controls vary by provider (e.g., AWS Glue, Nessie, Polaris), so governance models must align with platform capabilities.
- Disaster recovery for Iceberg tables involves backing up catalog metadata, leveraging snapshot rollback, and designing for cross-region resilience.
- Iceberg’s snapshot model provides powerful rollback options but also requires procedural safeguards to protect from unintended data loss.
- Simulating and automating recovery workflows helps validate readiness for real-world incidents and reduces recovery time.
FAQ
Why is orchestration essential for operating Apache Iceberg in production?
Orchestration turns Iceberg maintenance from manual, ad hoc work into repeatable, reliable, and observable workflows. Production Iceberg tables continuously accumulate snapshots, small files, delete files, manifests, and orphaned artifacts. Without automation, maintenance may run too often and waste resources, or too rarely and allow query latency, storage cost, and compliance risk to grow silently.
Tools such as Apache Airflow, dbt, Dagster, Argo Workflows, Prefect, or custom workflow engines can schedule and coordinate procedures like rewrite_data_files, expire_snapshots, rewrite_position_delete_files, and remove_orphan_files.
What is a DAG, and how is it used for Iceberg maintenance?
A DAG, or Directed Acyclic Graph, is a workflow structure where tasks run in a defined order without loops. In an Iceberg maintenance workflow, a DAG can ensure that one task completes before dependent tasks begin.
For example, an Airflow DAG might first query Iceberg metadata to check for small files, then run compaction only if a threshold is exceeded, then expire old snapshots, and finally remove orphan files. This makes maintenance predictable, auditable, and easier to debug.
How can Iceberg metadata tables drive proactive maintenance?
Iceberg exposes metadata views such as files, snapshots, manifests, history, and refs. These can be queried like tables and used to decide when maintenance is actually needed.
For example, the files metadata table can reveal how many files are below a target size, such as 20 MB. If the count exceeds a threshold, orchestration can trigger compaction. The snapshots table can reveal snapshot sprawl, while delete file metrics can indicate when Merge-on-Read tables need delete file rewriting or compaction.
Why should Iceberg maintenance policies be defined per table?
Different tables have different operational needs. A high-velocity CDC table may generate thousands of small files and frequent delete files, requiring frequent compaction and snapshot expiration. A monthly reporting table may only need lightweight maintenance after each monthly batch load.
Per-table policies allow teams to tune compaction frequency, snapshot retention, file size thresholds, orphan cleanup, and delete file rewriting based on table size, ingestion pattern, query importance, and compliance requirements. These policies can be stored in configuration files, catalog annotations, or table properties such as write.target-file-size-bytes, history.expire.min-snapshots-to-keep, and history.expire.max-snapshot-age-ms.
What should be monitored in a production Iceberg lakehouse?
A production Iceberg lakehouse should monitor metadata, orchestration, storage, and query engine behavior. Useful Iceberg metadata metrics include small file counts, snapshot counts, manifest growth, delete file accumulation, partition skew, and orphan file trends.
Engine-level metrics from Spark, Trino, Dremio, or Flink should also be tracked, including query planning latency, scan time, task failures, and resource contention. Orchestration logs from Airflow, dbt, or Dagster should be monitored for failed DAGs, skipped jobs, retry loops, and abnormal task durations. These metrics can be exported to tools such as Prometheus, CloudWatch, or Datadog for dashboards and alerts.
How does Iceberg support auditing and change tracking?
Iceberg creates a new snapshot for every table mutation, including appends, overwrites, deletes, updates, and schema changes. These snapshots form a built-in audit trail that records what changed, when it changed, and which files were added or removed.
Auditors and engineers can query the snapshots, history, manifests, and metadata_log_entries metadata tables to investigate changes. Snapshot summaries can reveal record counts added or removed, operation types, commit times, and lineage. This makes it possible to answer questions such as “What job changed this table?”, “When did row counts drop?”, or “Which files were affected by an overwrite?”
What are branches and tags used for in Iceberg governance?
Branches and tags provide version-control-like governance for Iceberg data. At the table level, Iceberg supports named snapshot references. A tag points to a fixed snapshot, making it useful for reproducible reporting or compliance checkpoints. A branch can move forward to newer snapshots, making it useful for development, QA, or controlled experimentation.
Catalog-level systems such as Project Nessie extend this idea across multiple tables, allowing teams to create isolated branches of an entire data environment. This supports testing, approval workflows, reproducibility, and safer promotion of changes into production. However, branches and tags must be governed carefully because referenced snapshots cannot be expired while they remain pinned.
How should snapshot and file retention be handled in Iceberg?
Retention in Iceberg is mainly enforced through snapshot expiration and orphan file cleanup. The expire_snapshots procedure removes snapshots that are no longer needed and makes unreferenced data or metadata files eligible for deletion. The remove_orphan_files procedure removes files that are not referenced by any valid Iceberg metadata, often left behind by failed or aborted writes.
Snapshot expiration should generally run before orphan file cleanup. Retention policies should vary by workload: staging tables may expire snapshots aggressively, while regulated production tables may retain snapshots for weeks or months, or pin them with tags for audit purposes.
Why is secure deletion in Iceberg more than just running a DELETE statement?
In Iceberg, a delete is first a logical change. In Copy-on-Write mode, affected data files are rewritten to exclude deleted rows. In Merge-on-Read mode, deletes are tracked separately using position delete files or deletion vectors, while the original data files may still physically contain the deleted rows.
For secure physical deletion, teams must coordinate the full lifecycle: issue the delete, compact or rewrite data files when necessary, expire snapshots that still reference old files, and clean up orphaned files. Branches, tags, retained snapshots, and delete files can all delay physical removal. This is especially important for GDPR, CCPA, and other compliance-driven deletion requirements.
What are the key disaster recovery practices for Apache Iceberg?
Disaster recovery for Iceberg must protect the catalog, metadata files, and data files. The catalog maps table names to current metadata locations, so catalog loss can make a table inaccessible even if all files still exist. Recovery often depends on restoring catalog state or re-registering a table with a known metadata.json file using procedures such as register_table.
Best practices include enabling object storage versioning, replicating data and metadata across regions, backing up catalog mappings, validating snapshot integrity, testing rollback_to_snapshot, and running regular recovery drills. Recovery workflows should be automated through tools like Airflow or Dagster and aligned with RPO and RTO requirements.
Architecting an Apache Iceberg Lakehouse ebook for free