nette / caching

⏱ Caching library with easy-to-use API and many cache backends.
https://doc.nette.org/caching
Other
415 stars 44 forks source link

FileStorage does not use atomic write #45

Open JanTvrdik opened 8 years ago

JanTvrdik commented 8 years ago

Couple of times per month I receive unserialize error ("Error at offset X of Y bytes") from RobotLoader which uses FileStorage. This suggests that FileStorage failed to write tha data properly. I alway delete the cache which solves the issue, obviously, but it is getting quite annoying so I've decided to finally open this issue.

Windows 10 x64, PHP 7.0.8 x64 NTS, FastCGI + Caddy

dg commented 7 years ago

I have never experienced such a problem.

podolinek commented 6 years ago

Similar bug for me, whole notice: PHP Notice: unserialize(): Error at offset 18 of 34 bytes in /project_dir/vendor/nette/caching/src/Caching/Storages/FileStorage.php:339 . It everytime occurs at the same page. Maybe some problematic string. I found this should be fixed by base64 encode/decode "hackfix" - davidwalsh blog with solution.

milo commented 6 years ago

Could you post here/somewhere contents of the unserialized file? To confirm atomic access issue or serialize/unserialize bug.

podolinek commented 6 years ago

Well, I don't know which file is the problem. It occurs approx. once a month and tracy log only notice row to error file without any other data.

milo commented 6 years ago

And how do you solve the issue? Deleting some file? Or not?

Btw, I don't think that mentioned blog solution is right. IMHO, they have some DB store/fetch issue and base64() only hides that bug.

podolinek commented 6 years ago

Every time "solved" by removing log file. When remove content of temp directory, no notice on problematic page created. Notice is created in random future time. Anyway, I just modified FileStorage in vendor for log variable $data on problematic page and when notice will be occurred, I will post it here. Hope it will be complete copyable content.