views:

290

answers:

2

The problem is that every so often a page that writes to a Session will cause apache to hang forever for a particular session. Once this error occurs for one user any further modifications to any session of any user will cause the website to hang for this user.

This problem has been my sole focus for days. I have a development VPS running Windows 2003 and default latest version of XAMPP using the standard PHP session handler. The code in question actually runs on two other machines perfectly normally so although my common sense says it’s a web server configuration issue but at this point I am willing to try anything.

On further investigation there are no errors in the Apache, PHP or System event log. Resources are abundant and there is no “AJAX shit storm” or more than a couple writes to a session per page. I have also implemented session_write_close() wherever possible to try and help elevate the problem.

I have checked the session’s directory which is set to “C:\windows\Temp” and found that once a user enters this hanging phase that the corresponding session file is exclusively locked and the only way to resolve this is to stop Apache and wait a few moments for the files to become unlocked and delete them. I am not wondering if deletion is required.

The Sessions themselves only contain 4 bits of information. ShoppingCartID, UserID, UserLevel and Refering URL and are alphanumerical with an occasional slash.

My PHP.INI’s session section is configured like this:

session.save_handler = files
session.save_path = "C:\WINDOWS\Temp"
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4

I have tried everything I can think of and the whole problem is now a blur to me. Any ideas would be appreciated and thanks for your time reading this :)

A: 

It could be your session files getting locked by Windows or some php.ini settings not done properly. Please SEE HERE

Almost want to say its the lock files.

jini
The php session settings are default with the exception of save_path which is only a security risk on shared servers which this is not.
Kmaid
A: 

Is it possible your app internally requests a page from the same site again internally? You could be hitting a race condition of sorts where page A fires up, locks the session, and then somehow triggers a request to itself, or page B, which also tries to re-start the session, which is now locked, and the request hangs.

Otherwise, if the hang is caused by the session file being locked, I'd suggest using something like SYSInternal's 'Handle' to get a list of what processes are using the session file in question.

Marc B
It is not possible. There are a few includes but no includes of includes and a maximum execution time is set.I am 99% sure its either apache or PHP that has the lock as it goes away after you stop and start the apache service. I will verify this anyway.
Kmaid