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

Save - Inside workerman event threads Save() throws fopen() error #911

Closed eharris2000 closed 5 months ago

eharris2000 commented 5 months ago

What type of issue is this?

Exception/Error/Warning/Notice/Deprecation

Operating system + version

Debian 12 Docker

PHP version

PHP 8.3.2-1+0~20240120.16+debian12~1.gbpb43448 (cli) (built: Jan 20 2024 14:14:39) (NTS)

Connector/Database version (if applicable)

Files Adapter

Phpfastcache version

9.2.0 āœ…

Describe the issue you're facing

Was seeing an issue during integration so created 5 test cases. Have phpfastcache running in two separate workerman threads. One thread creates items in the cache, the other thread reads items out of the cache and deletes them. On first pass, first worker inserts 3 items ( 1 every 3 seconds ). second worker ( 1 every 10 seconds ) reads the 3 messages. This functions properly. when the first worker makes its next pass ( second 12 ) I get a PHP Warning fopen(/tmp/phpfastcache/Files/79/dd/79dd8d25a5c369c941848966a79e5016.txt): Failed to open stream: No such file or directory in /home/resptech/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php on line 305

Unfortunately, the save function also return true. tests.tar.gz

Expected behavior

Should not throw error message and should save against subsequent calls.

Code sample (optional)

Uploaded samples as part of Describe Issue section. composer.json below

{ "require": { "firebase/php-jwt": "^6.5", "php-mqtt/client": "^1.8",
"monolog/monolog": "^3.4", "qmegas/memcache-search": "^0.1.2", "workerman/mqtt": "v1.5", "workerman/channel": "^1.2", "kreait/firebase-php": "7.9.1", "oittaa/uuid": "v1.9", "phpfastcache/phpfastcache": "9.2.3"
}, "require-dev": { "squizlabs/php_codesniffer": "dev-master", "phpstan/phpstan": "^1.10" },
"autoload": { "psr-4": { "tuuk\": "tuuk/", "app\": "app/" } } }

Suggestion to fix the issue (optional)

No response

References (optional)

No response

Do you have anything more you want to share? (optional)

No response

Have you searched in our Wiki before posting ?

github-actions[bot] commented 5 months ago

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

Geolim4 commented 5 months ago

Hello,

You're may facing concurrency issue. Since the Files driver is slow and disk-dependent, I suggest you to change the driver to redis :)

eharris2000 commented 5 months ago

test_4.php is with memcached. I can create a separate issue if you would like. In that test, memcached is used. It doesn't throw a file error. However, getItemsByTag() does not return items that have been tagged. However, if you inspect the memcached cache with a second file, the files are there.

Geolim4 commented 5 months ago

If such a huge bug like this happens my test suite would have flagged it a while ago.

Either you have a concurrency issue or a bug in your code.

Remember that cache item are stored statically in the pool manager, so when you're getting a cache item the same object will be served you each time if it still exists in the pool. (There's a an option to disable this behavior).

But honestly I can't help you here since tags are one of the most deeply tested feature of Phpfastcache.

On Mon, 11 Mar 2024, 4:57 pm eharris2000, @.***> wrote:

test_4.php is with memcached. I can create a separate issue if you would like. In that test, memcached is used. It doesn't throw a file error. However, getItemsByTag() does not return items that have been tagged. However, if you inspect the memcached cache with a second file, the files are there.

ā€” Reply to this email directly, view it on GitHub https://github.com/PHPSocialNetwork/phpfastcache/issues/911#issuecomment-1988783418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFGZZDJNH55C2BOGRJUKLYXXPATAVCNFSM6AAAAABEQNXU7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBYG44DGNBRHA . You are receiving this because you were assigned.Message ID: @.***>