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

Suppress cron errors while performing file cleanup #6480

Merged
merged 2 commits into from Oct 21, 2014
Merged

Suppress cron errors while performing file cleanup #6480

merged 2 commits into from Oct 21, 2014

Conversation

mgriego
Copy link
Contributor

@mgriego mgriego commented Oct 20, 2014

When performing simultaneous cron core:archive runs for large instances, there is a race condition during the file cleanup phase when one process sees the files of another process just before the other process deletes those files, causing the filemtime() call to fail since the file no longer exists. Also, since the return value from filemtime() is not checked for failure (=== FALSE), it tries to unlink() the file on failure, which also fails. At the least, this is causing unnecessary emailings from the cron process. The failure of filemtime() is harmless, though unlinking on that failure may not be. The filemtime() failure can be safely ignored since this function's only purpose is to clean up old files, and the failure just means the file no longer exists.

@mattab
Copy link
Member

mattab commented Oct 21, 2014

Thanks for the report!

instead of suppressing the warning could you maybe wrap in if( file_exists($path)) to check the file exists?

@mattab mattab added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Oct 21, 2014
@mattab mattab added this to the Short term milestone Oct 21, 2014
@mgriego
Copy link
Contributor Author

mgriego commented Oct 21, 2014

Yes, but that would still leave a small, albeit smaller than before, race window between when file_exists is called and filemtime is called. I do still think that the !== FALSE check needs to be there regardless just in case there are any other problems with the filemtime call, since that failure ends up allowing unlink() to be called, because FALSE is less than one week ago...

@mattab
Copy link
Member

mattab commented Oct 21, 2014

I do still think that the !== FALSE check needs to be there regardless

+1

mattab pushed a commit that referenced this pull request Oct 21, 2014
Suppress cron errors while performing file cleanup
@mattab mattab merged commit 83eb780 into matomo-org:master Oct 21, 2014
@mattab
Copy link
Member

mattab commented Oct 21, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants