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

Cache rarely cannot be read resulting in read exception #3

Open
Wruczek opened this issue Jun 28, 2019 · 3 comments · Fixed by #5
Open

Cache rarely cannot be read resulting in read exception #3

Wruczek opened this issue Jun 28, 2019 · 3 comments · Fixed by #5
Labels

Comments

@Wruczek
Copy link
Owner

Wruczek commented Jun 28, 2019

It seems like it happens randomly without any cause.

@Wruczek Wruczek added the bug label Jun 28, 2019
@Wruczek Wruczek changed the title Cache rarely cannot be read resulting in exception Cache rarely cannot be read resulting in read exception Jun 28, 2019
@007hacky007
Copy link
Contributor

Quickly scanning through the code - seems to be happening because you're not using file-locking and thus if you're accessing the file from more scripts running at the same time, you may get partial file because of the race-conditions. file_put_contents and file_get_contents are not atomic operations. This may be solved with LOCK_EX in the file_put_contents AND using flock around file_get_contents (or using flock/fopen instead of the file_get_contents altogether).

@Wruczek
Copy link
Owner Author

Wruczek commented Oct 8, 2022

Thank you for your tip! Now that I think about it, it might be the case. I will try to fix the issue by locking the file.

@Wruczek
Copy link
Owner Author

Wruczek commented Oct 20, 2022

Still needs testing to make sure the issue is fixed

@Wruczek Wruczek reopened this Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants