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

FileHandler Garbage Collector fails to delete expired session files. #942

Closed
timothymarois opened this issue Feb 19, 2018 · 4 comments
Closed
Labels
waiting for info Issues or pull requests that need further clarification from the author

Comments

@timothymarois
Copy link
Contributor

From testing on Amazon Linux EC2 with php 7.0 and php 7.1 the session files are not findable with the current file name detection. (using the default session save path)

I would request this be looked more into, I modified the script to at least get it working on my setup for the time being (example below)

On a higher note, there is something going on with PHP 7+ session gc. From many tests, it is failing to actually clear out the expired session files, I am not entirely sure if this is strictly a CI issue. But it has affected most of my CI projects on different servers.

This did not work on the server:

$pattern = sprintf('/^%s[0-9a-f]{%d}$/', preg_quote($this->cookieName, '/'), ($this->matchIP === true ? 72 : 40));

while (($file = readdir($directory)) !== false)
{
	// If the filename doesn't match this pattern, it's either not a session file or is not ours
	if ( ! preg_match($pattern, $file) || ! is_file($this->savePath . '/' . $file) || ($mtime = filemtime($this->savePath . '/' . $file)) === false || $mtime > $ts)
	{
		continue;
	}

	unlink($this->savePath . '/' . $file);
}

I ran this instead:

while (($file = readdir($directory)) !== false)
{
            $mtime = filemtime($savePath . '/' . $file);

            if (preg_match('|^ci_session|', $file) && $mtime < $ts)
            {
                unlink($savePath . '/' . $file);
            }

}

I did not look into which part of the if statement was causing this issue, but I am adding this here as it needs to be investigated further.

@lonnieezell
Copy link
Member

@timothymarois Can you check your php.ini file on your Amazon server and tell me what the values are for:

session.gc_maxlifetime = 3600
session.gc_probability = 1
session.gc_divisor = 1000

@jim-parry
Copy link
Contributor

This has come up a number of times on the forum, and appears to be a PHP garbage collector problem, no?

@jim-parry jim-parry added the waiting for info Issues or pull requests that need further clarification from the author label Oct 19, 2018
@lonnieezell
Copy link
Member

This was a slightly different one. IIRC from emails @timothymarois and I exchanged, it worked fine in a local dev environment, but completely failed on AWS servers to find the session files.

As for the garbage collection, that has definitely come up on the forums previously, and has typically been the php.ini file having a garbage collection time set to 0 or something like that.

This should still be looked into.

@lonnieezell
Copy link
Member

Closed via #1684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for info Issues or pull requests that need further clarification from the author
Projects
None yet
Development

No branches or pull requests

3 participants