Skip to content

feat(services): erase and retain capture data in iceberg tables - #135

Merged
TheMeinerLP merged 3 commits into
mainfrom
feat/iceberg-erasure
Nov 18, 2026
Merged

TheMeinerLP merged 3 commits into
mainfrom
feat/iceberg-erasure

Conversation

@TheMeinerLP

@TheMeinerLP TheMeinerLP commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A player who asked for erasure was not fully erased once the lake switches to Iceberg. The
erasure request showed as done, but the player's frames stayed readable in the events and
raw tables: the cleanup job only knew the Parquet files.

This PR closes that gap for the Iceberg mode only. Parquet mode does not change.

  • An erasure request removes the player's frames and raw payloads from both tables, by the
    player's key, plus frames of the player's sessions that carry no key. The older versions of
    the tables are then dropped right away, together with the files only those versions still
    used. Only files that no remaining version names are deleted, so a write that is still in
    progress is never touched. The data is then gone from storage, not just hidden from queries.
  • If a branch or tag still needs an older version of a table, nothing is dropped for that table.
    The request stays open and the erasure API shows why, so the hold can be found and released.
    The player's rows are already out of the current data.
  • Datasets built from the player are marked for a rebuild.
  • Raw payloads in Iceberg are no longer removed by the retention period. Only an erasure removes
    them.
  • Routine Iceberg maintenance stays with the platform's nightly Airflow DAG. Corvus housekeeping
    only does it when lake.maintenance.enabled is set (default off). Its orphan removal keeps a
    24 h margin.

Not in this PR

  • Backfill of the existing Parquet files into Iceberg.
  • Pinning dataset snapshots to Iceberg versions.
  • The column statistics of the erased files stay in the metadata of the erasure's own version
    until the table is written again. The rows themselves are gone.
  • A failed physical delete after expiry is left to the maintenance (or the DAG) to clean up.
  • A check against the real catalog. That is the next step after the merge, on a non-production
    replica.
  • An alert for held requests: they are visible in the log and in the API only.
  • The console does not show the new field yet.

Testing

  • Unit tests run on a local SQL catalog in a temporary directory: erasure of exactly one
    player's rows in both tables, removal from the data files, removal of files that an earlier
    untagged delete had dropped, no removal of files no expired version named, expiry of the older
    versions, refusal of a scan of an expired version, held erasure by a tag and by a branch, retry
    on a commit conflict and no retry on other errors, housekeeping maintenance that removes orphans
    only after 24 h and never deletes rows, and the compaction wiring with and without Iceberg.
  • Helm unit tests cover the Iceberg settings of the compaction and housekeeping jobs and the
    maintenance switch (off by default).
  • The new SQL (rebuild marks, blocked reason, pseudonym lookup) has statement-shape tests only.
    It has not run against a live PostgreSQL in this PR.
  • ruff, ruff format --check, mypy src, helm unittest and helm lint pass.

Layout, the erasure steps and the open points are in docs/reference/data-lake.md, section 2a
and section 7.

With CORVUS_LAKE_FORMAT=iceberg, corvus-compact now erases a player's rows from the events
and raw tables and expires the snapshots that still hold them. An erasure request completes
only when that succeeded. A branch or tag that keeps an older snapshot blocks the request,
and the API shows the reason. corvus-housekeeping expires old snapshots and removes orphan
files of the Iceberg tables; it never deletes rows.

- delete the rows of the pseudonym's sessions in chunks of 1000 session ids, one commit per
  chunk, each tagged with the request id; commit conflicts are retried with backoff
- expire every older snapshot right after the delete, then remove unreferenced files that
  are older than an hour
- mark the dataset snapshots that list the erased sessions as needs_rebuild
- add erasure_requests.lake_blocked_reason (migration 0008) and return it in the API
- parquet mode is unchanged
…eeping

The compaction and housekeeping CronJobs get CORVUS_LAKE_FORMAT from lake.format. With
iceberg they also get the catalog, OAuth and S3 settings of the lake block, the same secrets
as ingest. Housekeeping gets lake.snapshotRetentionDays (7).
Section 2a covers the erasure steps, the blocked state, the needs_rebuild mark and the
retention of raw in Iceberg. Section 7 points to it and lists the open points.
@TheMeinerLP
TheMeinerLP merged commit 6acd6bf into main Nov 18, 2026
17 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/iceberg-erasure branch November 18, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant