Skip to content

Randomly getting the phpFastCacheIOException #614

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

Closed
hriziya opened this issue Jun 8, 2018 · 19 comments
Closed

Randomly getting the phpFastCacheIOException #614

hriziya opened this issue Jun 8, 2018 · 19 comments

Comments

@hriziya
Copy link
Contributor

hriziya commented Jun 8, 2018

Configuration

  • PhpFastCache version: 6.0.2
  • PhpFastCache API version: 1.2.5
  • PHP version: PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )
  • Operating system: Ubuntu 16.04

I am using this since more than a year, and getting such permission exception once in a month or so.
It is completely random behavior and has no specific steps to duplicate it. Can anyone help with that?

I have checked the CacheManager class and the default setting is
'default_chmod' => 0777,

here are my doubts

  1. Should I use the "autoTmpFallback" = true in settings?
  2. If this is write permission issue, then it should trigger exception on every try of writing content to directory. so can anyone help me find the exact issue?

here is the detailed log of the exception message.

Fatal error: Uncaught phpFastCache\Exceptions\phpFastCacheIOException: PLEASE CHMOD /tmp/beta/Auto/Files/73/74 - 511 OR ANY WRITABLE PERMISSION! in /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/IO/IOHelperTrait.php:157

Stack trace:
#0 /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Driver.php(72): phpFastCache\Drivers\Files\Driver->getFilePath('all_types')

#1 var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/CacheItemPoolTrait.php(353): phpFastCache\Drivers\Files\Driver->driverWrite(Object(phpFastCache\Drivers\Files\Item))

#2 /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Helper/Psr16Adapter.php(84): phpFastCache\Drivers\Files\Driver->save(Object(phpFastCache\Drivers\Files\Item))

#3 /var/www/html/beta/web_services/_HELPER.php(1257): phpFastCache\Helper\Psr16Adapter->set('all_types', Array, 1200)

#4 /var/www/html/beta/web_services/service.php(417): HELPER in /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/IO/IOHelperTrait.php on line 157

@Geolim4
Copy link
Member

Geolim4 commented Jun 8, 2018

Hello,

I don't know what to say, tests are all green as you can see:
https://travis-ci.org/PHPSocialNetwork/phpfastcache

I may have a clue, but I need to see your cache code context :)
If it's sensitive, send me the sample at contact-at-geolim4.com

Thanks

Geolim4 added a commit to Geolim4/phpfastcache that referenced this issue Jun 8, 2018
@Geolim4 Geolim4 mentioned this issue Jun 8, 2018
5 tasks
@Geolim4
Copy link
Member

Geolim4 commented Jun 8, 2018

As I have no possibility to create a test for that, I'm going to push a preventive fix that should logically fix your issue.

Here's my clue:
https://github.com/kalessil/phpinspectionsea/blob/master/docs/probable-bugs.md#mkdir-race-condition

Geolim4 added a commit to Geolim4/phpfastcache that referenced this issue Jun 8, 2018
Geolim4 added a commit to Geolim4/phpfastcache that referenced this issue Jun 8, 2018
Geolim4 added a commit to Geolim4/phpfastcache that referenced this issue Jun 8, 2018
@Geolim4 Geolim4 mentioned this issue Jun 8, 2018
5 tasks
Geolim4 added a commit that referenced this issue Jun 8, 2018
Geolim4 added a commit that referenced this issue Jun 8, 2018
@Geolim4 Geolim4 closed this as completed Jun 8, 2018
@Geolim4
Copy link
Member

Geolim4 commented Jun 8, 2018

Fix will be available in the next release (around next week).

@hriziya
Copy link
Contributor Author

hriziya commented Jun 8, 2018

Thank you so much!

@Geolim4
Copy link
Member

Geolim4 commented Jun 8, 2018

Since the v6 had no new release since march, I'm gonna release one immediately.
The v7 will wait a bit more thought.

@Geolim4
Copy link
Member

Geolim4 commented Jun 8, 2018

Here you go:
https://github.com/PHPSocialNetwork/phpfastcache/releases/tag/6.1.3

@hriziya
Copy link
Contributor Author

hriziya commented Jun 13, 2018

Hey @Geolim4 , I am using the Latest release 6.1.3..
image

I am still seeing the error
Uncaught phpFastCache\Exceptions\phpFastCacheIOException: PLEASE CHMOD /tmp/beta/Auto/Files/5e/e0 - 511 OR ANY WRITABLE PERMISSION! in /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/IO/IOHelperTrait.php:157
Stack trace:
#0 /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Driver.php(72): phpFastCache\Drivers\Files\Driver->getFilePath('all_modules')

#1 /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/CacheItemPoolTrait.php(353): phpFastCache\Drivers\Files\Driver->driverWrite(Object(phpFastCache\Drivers\Files\Item))

#2 /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Helper/Psr16Adapter.php(84): phpFastCache\Drivers\Files\Driver->save(Object(phpFastCache\Drivers\Files\Item))

#3 /var/www/html/beta/web_services/_HELPER.php(1257): phpFastCache\Helper\Psr16Adapter->set('all_modules', Array, 1200)
#4 /var/www/html/beta/web_services/service.php(274): HE

here is the file created by phpfastcache
image

however, I have given the full right 777 to the parent directories.
image

I have checked the CacheManager.php and it has 'default_chmod' => 0777, so It should create file with 0777 I believe.

Let me know if this can be fixed.

Thank you

@Geolim4
Copy link
Member

Geolim4 commented Jun 13, 2018

Are you sure that you updated the right composer ?

Because I see that error in your stack:

Uncaught phpFastCache\Exceptions\phpFastCacheIOException: PLEASE CHMOD /tmp/beta/Auto/Files/5e/e0 - 511 OR ANY WRITABLE PERMISSION! in /var/www/html/beta/web_services/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/Pool/IO/IOHelperTrait.php:157

But it is not matching that line 157 updated in v6:
https://github.com/PHPSocialNetwork/phpfastcache/blob/v6/src/phpFastCache/Core/Pool/IO/IOHelperTrait.php#L157

But you have updated composer in /var/www/html/beta/web_panel/ while your error seems to be in /var/www/html/beta/web_services/ ?

@hriziya
Copy link
Contributor Author

hriziya commented Jun 13, 2018

Aaah, I see. Good catch buddy. Let me update it under /web_services and I will get back to you if needed.

Thank you

@hriziya
Copy link
Contributor Author

hriziya commented Jun 13, 2018

So, the issue with new files being created with wrong permission is fixed in 6.1.3?

@Geolim4
Copy link
Member

Geolim4 commented Jun 13, 2018

It has to be as per ab15efd

@Geolim4
Copy link
Member

Geolim4 commented Jun 13, 2018

@hriziya Is it working now ? :)

@hriziya
Copy link
Contributor Author

hriziya commented Jun 14, 2018

I have manually set the full permission to existing directories..

I did not see the error again, so it seems working..

@hriziya
Copy link
Contributor Author

hriziya commented Mar 17, 2020

I have faced this issue again on my another server where I have Ubuntu 18.04, PHP 7.4, nginx, and "phpfastcache/phpfastcache": "7.1.0" and I am using CacheManager

image

Do you think this could have happen due to multiple process try to access the same file (I have no idea about it though)..

I can easily overcome it by hiding the warning message, but as this is beta site, I used to keep it ON.
I am copying my code here to make sure it is setup correctly.

image

Let me know if I need to set any special settings?

@Geolim4
Copy link
Member

Geolim4 commented Mar 17, 2020

Nah it's your OS that clean up the temp directory, set a dedicated cache directory and the error will go away forever :)

/tmp should be for a temporary usage !

@hriziya
Copy link
Contributor Author

hriziya commented Mar 17, 2020

That make sense. Thank you.

@Kokil
Copy link

Kokil commented Mar 29, 2022

I got the same issue in version 8.1.2
The directory /tmp/phpfastcache/cli/Files could not be created. {"exception":"[object] (Phpfastcache\Exceptions\PhpfastcacheIOException(code: 0):

@Geolim4
Copy link
Member

Geolim4 commented Mar 29, 2022

I got the same issue in version 8.1.2 The directory /tmp/phpfastcache/cli/Files could not be created. {"exception":"[object] (Phpfastcache\Exceptions\PhpfastcacheIOException(code: 0):

Check the ownership/chmod permission of your cache directory. The tests are passing without any issue recorded:
https://app.travis-ci.com/github/PHPSocialNetwork/phpfastcache/jobs/562163535#L3991

@jaideejung007
Copy link

I got the same issue in version 8.1.2 The directory /tmp/phpfastcache/cli/Files could not be created. {"exception":"[object] (Phpfastcache\Exceptions\PhpfastcacheIOException(code: 0):

The same issue I encountered was resolved by specifying the proper host-allowed cache directory path. I specified the path as "/home/yourusername/domains/yourdomain.com/public_html/yourproject/data/cache" where I'm using DirectAdmin as the host for the control panel, and this problem is now fixed. ✅

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

No branches or pull requests

4 participants