Skip to content

Unexpected FileIO remove_all behavior for S3 #1118

Closed

Description

@c-thiel

Apache Iceberg Rust version

main branch

Describe the bug

Currently when using the S3 FileIO's remove_all method we noticed the following behavior:
Running remove_all('s3://foo/bar') removes s3://foo/bar* so also siblings such as s3://foo/bar-baz.

I would expect fileio to understand that I provide a folder, and only this folder and subfolders are removed, not siblings that have the same prefix.

@Xuanwo, @liurenjie1024, @Fokko do you agree? If so should we fix it in iceberg-rust or opendal?

To Reproduce

No response

Expected behavior

s3://foo/bar/* is deleted, not s3://foo/bar*

Willingness to contribute

I can contribute a fix for this bug independently

Activity

  1. added
    bug
    on Mar 20, 2025
  2. c-thiel commented on Mar 20, 2025

    @c-thiel
    CollaboratorAuthor

    ADLS Gen2 behaves differently. Even without a trailing slash siblings are not deleted.
    I think we should at least have consistent behavior, I would opt for the one described above.

    The question remains what behavior is desired in opendal

  3. liurenjie1024 commented on Mar 21, 2025

    @liurenjie1024
    Contributor

    I guess this is opendal's behavior, and it seems reasonable to append "/" at end if not present. cc @Xuanwo

  4. Xuanwo commented on Mar 21, 2025

    @Xuanwo
    Member

    OpenDAL treats input path as a prefix so remove_all("abc") will remove all keys that starts "abc" so it's expected that "abcd" will also be removed.

    The ADLS Gen2 behavior is not expected to me, it might be a bug that need to address.

    Back to iceberg, if we want to ensure that remove_all is just dir, we can always append a / to the path.

  5. Xuanwo commented on Mar 24, 2025

    @Xuanwo
    Member

    Hi, @c-thiel, what’s your expected behavior? I’m happy to help resolve this.

  6. c-thiel commented on Mar 27, 2025

    @c-thiel
    CollaboratorAuthor

    @Xuanwo I would slightly tend to only remove "abc" in your example, because its the safe default.
    My main point is however that behavior should be consistent across storages.

    GCS works like Azure. So out of those three, S3 is the odd one out.

  7. c-thiel commented on Mar 27, 2025

    @c-thiel
    CollaboratorAuthor

    I think if a client calls remove_all(table.location), this should work and be safe. So I would argue we should treat the input always as a directory / append a path.

  8. Xuanwo commented on Mar 28, 2025

    @Xuanwo
    Member

    Thank you @c-thiel, I will get this fixed.

    And also, I confirmed that the opendal behavior in ADLS Gen2 is wrong. I will take another look.

    GCS works like Azure. So out of those three, S3 is the odd one out.

    This is a surprise. Have you enabled gcs's Hierarchical Namespace for the bucket?

  9. Xuanwo commented on Mar 28, 2025

    @Xuanwo
    Member

    I think if a client calls remove_all(table.location), this should work and be safe. So I would argue we should treat the input always as a directory / append a path.

    I have a suggestion that rename this API to remove_dir_all which indicate that it only removes a dir recursively. And in this API, we make sure that both abc and abc/ works correctly. What do you think?

    This also aligns with std's remove_dir_all.

    Or are you expecting us to first check if abc/ exists and then decide whether to remove a prefix or a directory?

    I'm fine with both approaches at the iceberg FileIO side.

  10. liurenjie1024 commented on Mar 31, 2025

    @liurenjie1024
    Contributor

    I think if a client calls remove_all(table.location), this should work and be safe. So I would argue we should treat the input always as a directory / append a path.

    I have a suggestion that rename this API to remove_dir_all which indicate that it only removes a dir recursively. And in this API, we make sure that both abc and abc/ works correctly. What do you think?

    This also aligns with std's remove_dir_all.

    Or are you expecting us to first check if abc/ exists and then decide whether to remove a prefix or a directory?

    I'm fine with both approaches at the iceberg FileIO side.

    +1 for following std's naming convention to have different methods for remove_dir_all and remove_dir(for empty dir)

  11. self-assigned this
    on Apr 7, 2025
  12. Xuanwo commented on Apr 7, 2025

    @Xuanwo
    Member

    Nice, let me handle this.

  13. added this to the 0.5.0 Release milestone on Apr 7, 2025
  14. liurenjie1024 commented on Apr 21, 2025

    @liurenjie1024
    Contributor

    cc @Xuanwo Are we going to fix this ? It's the last issue in 0.5.0 release

  15. Xuanwo commented on Apr 21, 2025

    @Xuanwo
    Member

    cc @Xuanwo Are we going to fix this ? It's the last issue in 0.5.0 release

    Yep, let me do this in this week.

  16. liurenjie1024 commented on Apr 29, 2025

    @liurenjie1024
    Contributor

    cc @Xuanwo Do you have time to work on this? I can handle it if you are busy.

  17. Xuanwo commented on Apr 29, 2025

    @Xuanwo
    Member

    cc @Xuanwo Do you have time to work on this? I can handle it if you are busy.

    Will finish this today 😚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions