caching icon indicating copy to clipboard operation
caching copied to clipboard

FileStorage does not use atomic write

Open JanTvrdik opened this issue 9 years ago • 6 comments

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

JanTvrdik avatar Sep 03 '16 09:09 JanTvrdik

I have never experienced such a problem.

dg avatar Aug 18 '17 14:08 dg

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.

podolinek avatar Jul 20 '18 14:07 podolinek

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

milo avatar Jul 20 '18 20:07 milo

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.

podolinek avatar Jul 22 '18 14:07 podolinek

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.

milo avatar Jul 22 '18 15:07 milo

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.

podolinek avatar Jul 22 '18 16:07 podolinek