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

Warning from filesystem driver: mkdir(): File exists in /data/www/wrbm/corporate/prod/vendor/tedivm/stash/src/Stash/Driver/FileSystem.php on line 234 #372

Open
gggeek opened this issue Nov 13, 2017 · 5 comments

Comments

@gggeek
Copy link
Contributor

gggeek commented Nov 13, 2017

This is probably related to a race, where 2 processes might be trying to create the same directory at the same time.
My suggestion: if the mkdir call fails, check again if the dir exists and, if it does, use it

@gggeek
Copy link
Contributor Author

gggeek commented Nov 13, 2017

PS: might relate to #302

@tedivm
Copy link
Member

tedivm commented Dec 8, 2017

I have an idea on how to solve this (which will, unfortunately, only work on windows). However, when people start seeing this it's generally a sign that their traffic has increased to the point where they'd benefit from running the sqlite driver instead of the filesystem one.

@DavidGoodwin
Copy link
Contributor

I still see this problem at line 221 - https://github.com/tedious/Stash/blob/main/src/Stash/Driver/FileSystem.php#L221C13-L221C76

PHP Error: mkdir(): File exists from /x/y/vendor/tedivm/stash/src/Stash/Driver/FileSystem.php on line 221 {"errno":2,"errstr":"mkdir(): File exists","errfile":"/x/y/vendor/tedivm/stash/src/Stash/Driver/FileSystem.php","errline":221,

In our case, we seem to have amassed a ~30GB stash cache over 24 hours using the filesystem driver ( 'find' says this is about 1.8m files ).

I'm curious how running the purge/cleanup routine on the cache will work with PHP's stat cache when there are multiple processes involved. I'd normally have littered similar code with clearstatcache calls but I don't see any of these.

@tedivm you mentioned using Sqlite for high traffic instances; I seem to think sqlite often has a single process lock, so calling purge() might cause callers to be blocked?

I suspect I'll move back to using a Redis backend anyway.

@tedivm
Copy link
Member

tedivm commented Oct 14, 2023

If you're at the point where you've got 30gb in 24 hours I would use redis.

@DavidGoodwin
Copy link
Contributor

Yes - we are/were using Redis - but we hadn't changed the default eviction policy and a busy period led us to filling up the redis cache ... so as a hot fix I moved one thing to use a filesystem cache (hence seeing the above mkdir thing!)

I was just wondering if having a table a bit like this to help people choose cache backends (my pros/cons are likely to be incorrect)

Driver Pros Cons
FileSystem Simple to setup, good for low concurrency and smaller caches Requires manual maintenance schedule (possibly time consuming), may struggle under high concurrency, not distributed.
Redis more scalable requires service/server, might be a spof
APC v. fast, no network dependency very limited size, per-process (?) so limited scalability
Memcache network service, scalable requires memory, not as feature rich as redis
Sqlite good for mostly read caches, no network dependency may not handle high concurrency well, requires maintenance schedule

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

3 participants