Skip to content

Don't set session.gc_probality=1, instead read value from config #15274

@Jakhotiya

Description

@Jakhotiya

@ini_set('session.gc_probability', 1);

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.sock
In 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

  1. update code base with something like
@ini_set(Config->getInstance()->General['session_gc_probability']);

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help wantedBeginner friendly issues or issues where we'd highly appreciate community's help and involvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions