Skip to content

fix(caching): publish cache files atomically and preserve unknown history - #1833

Open
JustinBinber wants to merge 1 commit into
apache:mainfrom
JustinBinber:codex/fix-cache-publication-edge-cases
Open

JustinBinber wants to merge 1 commit into
apache:mainfrom
JustinBinber:codex/fix-cache-publication-edge-cases

Conversation

@JustinBinber

Copy link
Copy Markdown
Contributor

A failed result-file write can leave a partial file that a refresh retry mistakes for a complete cached result. Legacy history with an unknown version can also adopt later recomputed mappings. This follows up on #1820 and fixes #1832.

  • Serialize first, write the result record to a same-directory temporary file, close it before replacement, and clean up handled failures. Expiry scans ignore the identifiable .hamilton-*.tmp staging files, including residue from an interrupted process.
  • Read each history row's stored version and omit unknown legacy snapshots. Keep the existing once-only migration/backfill and mapping-deletion behavior.
  • Cover partial writes with and without an existing result, failed replacement, a real Driver refresh retry, expiry scanning during creation and with abandoned staging files, and repeated refreshes/reopening after an unknown legacy snapshot.

Validation on Windows / Python 3.11:

  • All 7 new regression cases pass. The original five cases failed before the fix; the two expiry cases failed before the staging-file filtering amendment.
  • Explicit offline caching/fingerprinting/store/integration and legacy cache-adapter suite: 163 passed, 3 optional Polars skips, 1 pre-existing failure. The failing test_dataframe_with_unhashable_cells_does_not_fail also fails on untouched main at b3992d3a6802961235568bba4d0d6d654923c6f1, because <unhashable>_... is an invalid Windows filename.
  • Project pre-commit hooks and git diff --check pass.

The atomic replacement covers the serialized result/loader record. Arbitrary materializer sidecars retain their existing behavior; this does not introduce a multi-file transaction or an fsync durability guarantee. Abrupt process termination may leave ignored staging files.

This branch has not been deployed

No deployments
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.

Cache retries can publish partial results and rewrite unknown legacy history

1 participant