Skip to content

Don't warn when an old metadata file is already deleted - #4617

Open
Zu67 wants to merge 1 commit into
apache:mainfrom
Zu67:fix/4612-missing-metadata-delete-warning
Open

Zu67 wants to merge 1 commit into
apache:mainfrom
Zu67:fix/4612-missing-metadata-delete-warning

Conversation

@Zu67

@Zu67 Zu67 commented Dec 4, 2026

Copy link
Copy Markdown

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 in delete_files() and logs Failed to delete metadata file ... on every commit, even though the file is already gone.

This change treats FileNotFoundError in delete_files() as "already deleted" and logs it at debug level instead. Other OSErrors, such as permission errors, still produce the warning. The issue asked whether delete_files should ignore FileNotFoundError or 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_warn sets write.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_errors checks that a permission error still logs the warning. tests/catalog/test_catalog_behaviors.py passes (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=true no 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.

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

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.

"Failed to delete metadata file" warning on every commit with a REST catalog

1 participant