-
Couldn't load subscription status.
- Fork 537
fix: use a safe checkpoint when cleaning up metadata #3748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
ACTION NEEDED delta-rs follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
|
Overview via copilot. Pull Request OverviewThis PR upgrades the
Changes
|
3b47e8c to
422034b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3748 +/- ##
=======================================
Coverage 76.10% 76.10%
=======================================
Files 145 145
Lines 45169 45200 +31
Branches 45169 45200 +31
=======================================
+ Hits 34376 34400 +24
- Misses 9101 9105 +4
- Partials 1692 1695 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
python/tests/test_table_read.py
Outdated
| file = log_path / f"0000000000000000000{expected_version - 1}.json" | ||
| assert not file.exists() | ||
| if expected_version > 0: | ||
| assert file.exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamreeve This could maybe use improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is nonsensical for expected_version = 0. But for expected_version = 1, log files for version 0 and 1 have timestamps outside the retention period. A checkpoint is created for version 1, so I would expect that the file for version 0 is deleted and only version 1 and above are retained. Which is what happened before but this has changed.
Debugging this, I can see that this is due to using the timestamp of the checkpoint file rather than the log file in the cleanup logic. Although the log file for version 1 is outside the retention period, the new checkpoint was only just created so it's inside the retention period, and we end up aborting the cleanup here: https://github.com/corwinjoy/delta-rs/blob/437df15dc4a047f9bc5065e881498a8591b61bcd/crates/core/src/protocol/checkpoints.rs#L269
Maybe the cleanup logic should use the timestamp on the log file corresponding to the checkpoint, rather than the timestamp on the checkpoint itself? As it seems like this scenario could happen in real usage, not just tests, where users might create a checkpoint long after a version is created and just before running cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I updated the logic as we discussed. See corwinjoy#15
The new logic for the function is:
- Find the minimum version for the log files in the retention period. That is, min(version) for files matching DELTA_LOG_REGEX and ts >= cutoff_timestamp. Call this min_retention_version. If empty, set to keep_version.
- Let keep_version = min(keep_version, min_retention_version).
- Find the safe checkpoint, where checkpoint_version <= keep_version. (No timestamp restriction). Call this version safe_checkpoint_version.
- Delete files matching DELTA_LOG_REGEX where log_ver < safe_checkpoint_version && ts <= cutoff_timestamp.
0710652 to
73c3ed4
Compare
Inside the function table.cleanup_metadata look for the last checkpoint before the requested minimum cutoff time and version. Only delete files before that checkpoint. This is to fix the bug below and make sure that versions inside the retention period are still loadable. Signed-off-by: Corwin Joy <[email protected]>
Signed-off-by: R. Tyler Croy <[email protected]>
73c3ed4 to
99d733d
Compare
# Conflicts: # crates/core/tests/checkpoint_writer.rs
Signed-off-by: Corwin Joy <[email protected]>
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Signed-off-by: Corwin Joy <[email protected]>
Signed-off-by: Corwin Joy <[email protected]>
4a6749c to
160de90
Compare
Signed-off-by: Corwin Joy <[email protected]>
…andas Signed-off-by: Corwin Joy <[email protected]>
Head branch was pushed to by a user without write access
|
@rtyler To fix the failing CI test, (https://github.com/delta-io/delta-rs/actions/runs/18060977418/job/51397176816), I went ahead and updated |
…ke it clear the correct version is retrieved Signed-off-by: Corwin Joy <[email protected]>
Rebase failed
|
Thanks @rtyler ! |
Description
Inside the function
table.cleanup_metadatalook for the last checkpoint before the requested minimum cutoff time and version. Only delete files before that checkpoint. This is to fix the bug below and make sure that versions inside the retention period are still loadable.Related Issue(s)
Fixes #3692