Results 1 to 7 of 7

Thread: SessionHandler::gc(): ps_files_cleanup_dir: opendir() failed: Permission denied (13)

  1. #1
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    35

    Default SessionHandler::gc(): ps_files_cleanup_dir: opendir() failed: Permission denied (13)

    I can't believe it's year 2020, php 7.4 is available, Contao 4.9.2, and I'm still fighting this error every once in a while!
    Code:
    [2020-05-02 20:49:37] request.CRITICAL: Uncaught PHP Exception ErrorException: "Notice: SessionHandler::gc(): ps_files_cleanup_dir: opendir(/tmp/phpfpmsessions/) failed: Permission denied (13)" at /www/htdocs/w0123456/someserver.com/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php line 101 {"exception":"[object] (ErrorException(code: 0): Notice: SessionHandler::gc(): ps_files_cleanup_dir: opendir(/tmp/phpfpmsessions/) failed: Permission denied (13) at /www/htdocs/w0123456/someserver.com/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php:101)"} []
    Turns out, I already solved it once, 2 years ago, and I don't remember. I googled now and found this thread. I read it twice before realizing, that I already posted there at the time.
    So, I'm posting here rather for my future self, when I will be looking for the solution next time (if the moderator allows – Hallo, Spooky!)

    TL;DR
    The session.gc_probability=0 in php.ini is indeed a correct setting, to disable PHP's native garbage collection, since many Linux systems have their own CRON job for this, which causes the conflict.
    The problem is – Symfony doesn't respect your settings in php.ini, please read here: https://symfony.com/doc/4.4/componen...age-collection:

    However, some operating systems (e.g. Debian) do their own session handling and set the session.gc_probability variable to 0 to stop PHP doing garbage collection. That's why Symfony now overwrites this value to 1.

    If you wish to use the original value set in your php.ini, add the following configuration:

    Code:
    # config/packages/framework.yaml
    framework:
        session:
            gc_probability: null
    For Contao, you can just put it in config.yml instead.

    I have to add, my hoster is All-Inkl.

  2. #2
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,244

    Default

    Weird, I never had such a problem with All-Inkl. Do you get this error only with PHP 7.4?
    Contao Community Moderator
    → Support options

  3. #3
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    35

    Default

    It is a rare and obscure problem indeed.
    Forgive me for not being clear, it was somewhat a joke about modern PHP versions... I'm actually on php7.2, and 2 years ago (in that other thread) it was 7.1

    What I don't understand (since we are talking about All Inkl), is that the error is about not being able to read from /tmp/phpfpmsessions, but this folder doesn't exist actually (I don't see it via SSH), so it's not the access rights problem. Moreover, this setting (session.save_path) comes from /etc/php72/fpm/php.ini file, which also doesn't exist

    Or may be I just don't know something about shared server administration (most probably)...

  4. #4
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,244

    Default

    What does the All-Inkl support say about this? Have you already asked them?
    Contao Community Moderator
    → Support options

  5. #5
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    35

    Default

    Quote Originally Posted by xchs View Post
    What does the All-Inkl support say about this? Have you already asked them?
    As far as I understand (my German is not very good) – some php processes took very long to respond. From my side it looks like the websites become unresponsive for some minutes, which leads to Gateway timeout error.

  6. #6
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    35

    Default

    It seems a really small chance to hit this problem, but now I actually remember, that I had it 2 years ago (C4.4) to the extent that the website was hanging many times throughout the day.
    Applying that Symfony setting from my original post solved it in a very obvious way, instantly.

  7. #7
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    35

    Default

    a couple more links for the history:
    https://github.com/symfony/symfony/pull/10366
    https://tideways.com/profiler/blog/p...nce-bottleneck

    I need someone experienced to verify, that I understand correctly, because I prefer to know what I'm doing when changing any setting.

    From what I understand, Symfony uses it's own tmp folder to store sessions, and to perform garbage collection in it, Symfony overwrites gc_probability to "1". However, in Ubuntu 18.04 (which All Inkl provides), Contao application uses system's tmp folder, which is cleaned up by Ubuntu's own cron job. So in this case, I need to set gc_probabilty: null in my config.yml again, otherwise Symfony's garbage collector tries to delete "zombie folders" every once in a while, issues a notice, the whole thing takes too long and I end up with "Gateway timeout" in my websites.

    Is it correct?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •