#2833·s3fs-fuse

rmdir is called before calling unlink all files in directory on macOS

Author: ggtakecCreated Apr 6, 2026Updated Apr 7, 2026

The test_truncate_cache test occasionally failed on macOS, but I have now identified the direct cause.

The test_truncate_cache test creates two directories, each containing 75 files, and then deletes both directories. Normally, for non-empty directories, unlink is called for each file within the directory, and rmdir is called only after the directory is empty.

However, when this problem occurs, the following is logged as example:

...
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/74][pid=0,uid=501,gid=20]
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/75][pid=0,uid=501,gid=20]
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/8][pid=0,uid=501,gid=20]
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/9][pid=0,uid=501,gid=20]
...
[INF] s3fs.cpp:s3fs_rmdir(1360): [path=/testrun-21005/2][pid=0,uid=501,gid=20]
...
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/46][pid=0,uid=501,gid=20]
[INF] s3fs.cpp:s3fs_unlink(1303): [path=/testrun-21005/2/45][pid=0,uid=501,gid=20]
...

In the example above, the deletion of 2 directory is called before the deletion of the 2/46 and 2/45 files. Therefore, an error occurs when it tries to delete a non-empty directory.

@macos-fuse-t This looks like a fuse-t issue, should I submit an issue to https://github.com/macos-fuse-t/fuse-t?

@gaul I plan to submit a PR with temporary workaround code to reduce the occurrence of this issue. Also, I disabled some functionality in #2783 due to the possible cause of this issue, and I will submit a PR to revert this.