Zu67 opened a new pull request, #4617:
URL: https://github.com/apache/iceberg-python/pull/4617

   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 `OSError`s, 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to