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] Cache read failures with FileStore driver #2275

Closed
fturmel opened this issue Sep 13, 2013 · 3 comments
Closed

[Cache] Cache read failures with FileStore driver #2275

fturmel opened this issue Sep 13, 2013 · 3 comments

Comments

@fturmel
Copy link
Contributor

fturmel commented Sep 13, 2013

We recently launched a site using Laravel 4 and noticed cache reading related errors in our PHP logs. These seem to happen about 3 times a day so far and we are getting on average about 200 requests per minute. We are using the FileStore driver. Most of the cached content has a TTL of 60 minutes.

Here is a truncated stack trace of one of these events.

[2013-09-11 17:26:57] log.ERROR: exception 'ErrorException' with message 'file_get_contents(/var/www/site/app/storage/cache/12/2f/122f8f5cbff4807f3b06cf5d2256355b): failed to open stream: No such file or directory' in /var/www/site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:29
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'file_get_conten...', '/var/www/sites/...', 29, Array)
#1 /var/www/site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(29): file_get_contents('/var/www/sites/...')
#2 /var/www/site/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(52): Illuminate\Filesystem\Filesystem->get('/var/www/sites/...')
#3 /var/www/site/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(49): Illuminate\Cache\FileStore->get('9756dee4a3bf000...')
#4 /var/www/site/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(37): Illuminate\Cache\Repository->get('9756dee4a3bf000...')
#5 /var/www/site/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(80): Illuminate\Cache\Repository->has('9756dee4a3bf000...')
#6 [internal function]: Illuminate\Cache\Repository->remember('9756dee4a3bf000...', 60, Object(Closure))
[...]

From what I understand the cache file may be getting removed by another process in between the is_file and file_get_contents in the Filesystem class.

Maybe it's as simple as wrapping this part of the FileStore or Filesystem in a try/catch to be able to handle this case correctly?

Also wondering if this type of issue could happen with other drivers...

@taylorotwell
Copy link
Member

Fixed.

@benbowler
Copy link

Strangely I have this bug on a live server now. How did you fix.

@GrahamCampbell
Copy link
Member

Strangely I have this bug on a live server now. How did you fix.

Your should not be using the file drivers in prod. They are there to give people a quick start only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants