Bug #76368 [Fbk->Asn]: Garbage collection configuration not handled correctly.
| From: | Alastair dot Growcott at dynautics dot com | Date: | Wed, 23 May 2018 13:07:07 +0000 |
| Subject: | Bug #76368 [Fbk->Asn]: Garbage collection configuration not handled correctly. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215343@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76368&edit=1
ID: 76368
User updated by: Alastair dot Growcott at dynautics dot com
Reported by: Alastair dot Growcott at dynautics dot com
Summary: Garbage collection configuration not handled
correctly.
-Status: Feedback
+Status: Assigned
Type: Bug
Package: Session related
Operating System: Ubuntu
PHP Version: 7.0.30
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Does the cron job use the gc_maxlifetime value in the php.ini file?
The documentation says:
-----
session.gc_maxlifetime integer
session.gc_maxlifetime specifies the number of seconds after which data will be seen as
'garbage' and potentially cleaned up. Garbage collection may occur during session start
(depending on session.gc_probability and session.gc_divisor).
Note: If different scripts have different values of session.gc_maxlifetime but share the
same place for storing the session data then the script with the minimum value will be cleaning the
data. In this case, use this directive together with session.save_path.
-----
There is no mention of the cron job here so if there is a cron job and it is using this value then
the documentation needs updating.
Also I don't see any sign of any cron job. What user/crontable will it be running under?
Previous Comments:
------------------------------------------------------------------------
[2018-05-23 10:01:39] cmb@php.net
> Ubuntu is Debian based and likely also uses a Cronjob by default
It looks like this is the case here, isn't it?
------------------------------------------------------------------------
[2018-05-23 07:49:17] spam2 at rhsoft dot net
Ubuntu is Debian based and likely also uses a Cronjob by default as any smart setup - under load its
not funny have the burden of deal with thousands of files in the webserver with likely collisions
that more than one worker triggers the cleanup
------------------------------------------------------------------------
[2018-05-23 06:53:57] Alastair dot Growcott at dynautics dot com
Description:
------------
The exact version is PHP 7.0.30-0ubuntu0.16.04.1 and is running in a Docker container for a website.
I got the version running the CLI command though.
My settings are:
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
As I understand the documentation, having a probability of 0 means that garbage collection should
never happen. However I am finding my session is losing all its values after about 30 minutes (I
have never measured it exactly). I increased the gc_maxlifetime value to 144000 and after 5 hours
the session was still in existance.
This started happening after a recent rebuild of my Docker container when I moved from one server to
another. It looks as if the meaning of a gc_probability value of zero has been changed from
"never" to "always".
Test script:
---------------
I haven't tested it, but this should reproduce the problem:
<?php
session_name("Demonstration");
$result = session_start(['cookie_lifetime' => 86400]);
if (!$result) {
echo "Failed to start session.";
} else if (isset($_SESSION['test_value'])) {
echo "Bug didn't happen.";
} else {
echo "Starting new session."
}
?>
Create a website with this script and the settings above. Load the page. Wait about 30 minutes. Load
the page again. You can shorten the wait by reducing session.gc_maxlifetime in the configuration.
Expected result:
----------------
On the first load you should see "Starting new session.". On the second load after some
time you should see "Bug didn't happen.".
Actual result:
--------------
Instead of "Bug didn't happen." you will see "Starting new session." as the
session has been garbage collected.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76368&edit=1