Skip to content

Comments

fix: handle AlreadyExists race in create_dir_all#381

Open
raema wants to merge 1 commit intobytedance:masterfrom
raema:fix-create-dir-all-race
Open

fix: handle AlreadyExists race in create_dir_all#381
raema wants to merge 1 commit intobytedance:masterfrom
raema:fix-create-dir-all-race

Conversation

@raema
Copy link

@raema raema commented Jan 29, 2026

Problem

monoio::fs::create_dir_all can return AlreadyExists when two tasks create the same directory at the same time.

Approach

If mkdir fails, check whether the path is now a directory. If it is, treat the operation as successful. Otherwise return the original error.

The fix adds a check after mkdir:

  • mkdir succeeds -> OK
  • mkdir fails but is_dir() is true -> OK (another task already created it)
  • otherwise -> return the error

@CLAassistant
Copy link

CLAassistant commented Jan 29, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants