Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXP-3032: Race condition during local.buffer.dir creation #43

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

ramanenka
Copy link

When multiple tasks are starte on the same worker all of them are trying to check if the directory exists and create if not. Sometimes some of the tasks fail because the directory gets created after the existence check and before the creation attempt by other tasks.

The fix is to do a few attempts of checking and creating the directory.

When multiple tasks are starte on the same worker all of them are
trying to check if the directory exists and create if not. Sometimes
some of the tasks fail because the directory gets created after
the existence check and before the creation attempt by other tasks.

The fix is to do a few attempts of checking and creating the directory.
@ramanenka ramanenka requested a review from a team February 14, 2024 17:40
if (!directory.exists() && !directory.mkdirs()) {
int attempts = 3;
while (attempts > 0 && !directory.exists() && !directory.mkdirs()) {
attempts--;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really work without sleep?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sleep won't change anything here. By the time it fails, the directory already exists: the adjacent task on the same worker is faster with creating it.

@ramanenka ramanenka merged commit baa5e2c into sugarcrm:master Feb 15, 2024
1 check passed
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