-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Don't set session.gc_probality=1, instead read value from config #15274
Comments
@Jakhotiya this FAQ might be bit outdated. We're using DB sessions by default which are working nicely in a load balanced environment and I'm thinking we will be deprecating support for this. There shouldn't really be a need for using Redis sessions over DB. |
@tsteur You would have this problem even with DB right? Because when session_start() will still try to cleanup sessions file system directory. ps_files_cleanup_dir is called before session start. Am I missing something? |
@diosmosis do you maybe know more about it? If it doesn't have an effect on the DB, we could probably remove it? |
It affects when session GC is called, and the |
@diosmosis @tsteur it has nothing to do with redis handler. it has everything to do with "ps_files_cleanup_dir" which is called when we call session_start() function. Strangely there is no official php doc for "ps_files_cleanup_dir"; See if this link helps. The bug I'm reporting will creep up with many different php frameworks that set gc_probability=1 This thing happens even when I'm not using redis session handler. I see this on our production environment when GC is triggered. |
@tsteur we could add the INI config setting pretty easily, what do you think? |
@diosmosis I can send a pull request. |
Sounds good 👍 |
@Jakhotiya feel free to create a PR 👍 |
matomo/core/Session.php
Line 134 in 76102d2
As in the code snippet above setting
session.gc_probability=1
in general causes problems for different environments. For example our session handler is redis and session save_path for webserver is /var/run/redis.sockIn this case automatic garbage cleanup will attempt to cleanup a directory to which it does not have access to, For example, opendir(/var/lib/php/session) failed: permission denied fails in my case.
As a result I see errors like
ERROR Piwik\Session[2019-12-12 09:14:06 UTC] [2267b] Unable to start session
Occasionally which are frequent but hard to reproduce.
Many systems do not give permission to session directory because they have some kind of cron to periodically clear expired session files. Just the php recommendation
When you are using redis for php sessions there is no need for garbage collection since TTL will take care of removing old sessions. Hence session.gc_probability should be zero.
Now, this concerned me because link to configure redis for matomo sessions
Should we
2.) Just update the FAQ link with help..(I don't know what help. How do we tell matomo not to force gc_probability to 1? Is there an event? Can I do Dependency injection?)
3.) leave it alone for now
The text was updated successfully, but these errors were encountered: