PHPSocialNetwork / phpfastcache

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
https://www.phpfastcache.com
MIT License
2.36k stars 452 forks source link

Files driver edge-case "failed to open stream: No such file or directory" when writing #798

Closed zanderwar closed 3 years ago

zanderwar commented 3 years ago

Configuration

Describe the bug

fopen(/full/path/to/files/cache/storage/Files/55/86/55860346fb35b4cb9f90bacc1b97affc.txt): failed to open stream: No such file or directory 

To Reproduce Not sure. Used by a few thousand sites, collectively this error has only occurred 4 times, there are no folder permission errors, and it has no issue writing as there is already an ungodly amount of cache files being used successfully.

1 File "/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php" line 355
2 File "/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php" line 355 in fopen [args]
3 File "/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Files/Driver.php" line 106 in Phpfastcache\Drivers\Files\Driver::writefile [args]
4 File "/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php" line 442 in Phpfastcache\Drivers\Files\Driver::driverWrite [args]

If you need anymore information, please let me know

Thank you for providing and maintaining this package :)

github-actions[bot] commented 3 years ago

Hello curious contributor ! Since it seems to be your first contribution, make sure that you've been:

Geolim4 commented 3 years ago

Hello,

This "error" has been reported multiple time and I can't fix it at all because it's not reproducible at all and it is more related to a race condition server-side.

Currently pfc is heavily tested with multiple concurrent requests and this bug does not appears at all (see our Travis builds).

I'm recommending you to migrate to a more reliable backend such Redis and similar.

Files driver should be reserved on small sites with low traffic or environment developments.