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

Modifying the compressFile function to correct intermittent log file rotation crashes #80

Closed
wants to merge 1 commit into from

Conversation

wufe-natuku
Copy link

I have been encountering log rotation crashes mentioned in issue #9 almost constantly on my production server. While working through the issue, I have come to believe the cause is a race condition in the compressFile function. The file to be archived is opened for read and them piped into the compressor. This pipe is an asynchronous action. Right after that, the file is unlinked. I believe there is a race condition between the unlinking and the openning for compression. If the file is not opened before the unlink occurs, the unlink will delete the file. This in turn causes the failure to open because the file is gone.

After doing some reading about the pipe and unlink functions, I am proposing this fix.
If you wait to unlink until the pipe finishes, the race condition is gone. This fix has cleared up the issue on my production server.

…er it has been compressed. I believe there is a race condition between the compression and the unlink and when the unlink whens it throws an ENOENT error.
@mattberther
Copy link
Member

@wufe-natuku Thank you for your contribution. Would you please update to make sure the unit tests pass? I suspect it's likely a timing issue that's causing it. Thanks!

@mattberther
Copy link
Member

Some long-overdue refactoring of the transport has occurred. Closing this PR in favor of #107.

@mattberther mattberther closed this Nov 6, 2017
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