Skip to content

Fix intermittent mkdir race when generating with multiple workers#222

Open
mynetx wants to merge 1 commit into
statamic:4.xfrom
mynetx:fix/worker-mkdir-race
Open

Fix intermittent mkdir race when generating with multiple workers#222
mynetx wants to merge 1 commit into
statamic:4.xfrom
mynetx:fix/worker-mkdir-race

Conversation

@mynetx

@mynetx mynetx commented Jul 4, 2026

Copy link
Copy Markdown

When generating with multiple workers, a page would intermittently fail with:

[✘] /fr (mkdir(): File exists)

Two workers can race on the same output directory: one checks that it doesn't exist, another creates it in the meantime (e.g. while writing a child page like /fr/stories/...), and the first worker's mkdir then throws. Since pages are shuffled across workers, it's timing-dependent — on a small 13-page multisite it failed 5 out of 20 runs with --workers=4.

This forces the directory creation, so an already-existing directory is treated as success. Genuine failures (permissions etc.) still surface through the put() right after. With the fix, the same 20-run loop passes cleanly.

Co-Authored-By: Claude noreply@anthropic.com

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant