Repository navigation
Conversation
With write.metadata.delete-after-commit.enabled, a REST catalog server can remove old metadata files during the commit. The client then tries to delete them again in delete_files and logs 'Failed to delete metadata file' on every commit, even though the file is gone. Treat FileNotFoundError as already deleted and log it at debug level. Other OSErrors, such as permission errors, still produce the warning. Closes apache#4612
Fokko
left a comment
There was a problem hiding this comment.
Thanks @Zu67! Nice fix 👍 Verified that the new test fails without the change and passes with it.
One question: in purge_table, manifests are read via fetch_manifest_entry (pyiceberg/catalog/__init__.py:369) and snapshot.manifests() without catching FileNotFoundError, so with a REST catalog that removes files eagerly, a purge could still raise before delete_files is reached. Is that on purpose, or worth a follow-up issue? Out of curiosity, did you run into that in practice?
|
Thanks for checking it, @Fokko! Leaving out |
Closes #4612
Rationale for this change
With
write.metadata.delete-after-commit.enabled=true, a REST catalog server can remove old metadata files during the commit. The client then tries to delete those same files indelete_files()and logsFailed to delete metadata file ...on every commit, even though the file is already gone.This change treats
FileNotFoundErrorindelete_files()as "already deleted" and logs it at debug level instead. OtherOSErrors, such as permission errors, still produce the warning. The issue asked whetherdelete_filesshould ignoreFileNotFoundErroror whether the client should skip deletion for REST catalogs. This takes the first option, so SqlCatalog and other catalogs keep cleaning up old metadata as before.Are these changes tested?
Yes.
test_delete_metadata_already_removed_by_server_does_not_warnsetswrite.metadata.previous-versions-max=2, deletes the oldest metadata file before each commit to stand in for the server, and checks that no warning is logged. It fails without the fix and passes with it on the memory and SqlCatalog fixtures.test_delete_files_still_warns_on_other_os_errorschecks that a permission error still logs the warning.tests/catalog/test_catalog_behaviors.pypasses (872 passed), and ruff check and format are clean.Are there any user-facing changes?
Yes. Users of REST catalogs with
write.metadata.delete-after-commit.enabled=trueno longer get a "Failed to delete metadata file" warning on every commit. Purge-table cleanup also no longer warns about files that are already missing.