PHP Warning: session_start(): Unable to clear session lock record in
/var/www/efs/html/v43/Api/PortalApi/PortalApi.php on line 39
When multiple request are made simultaneously, the above issue occurs in one of our dev environment but other environments are working fine. could not resolve the reason for it.
Your problem was the user concurrency.
Setting the following ini settings (also from PHP directly) can help to mitigate this issue on a high load project
I recommend disable session.lazy_write in php.ini
You can try this too:
ini_set('memcached.sess_lock_retries', 10);
ini_set('memcached.sess_lock_wait_min', 1000);
ini_set('memcached.sess_lock_wait_max', 2000);
We fixed the issue, the problem -> in a recent code change in dev environment multiple logs was added in the code for testing configuration, the writing of multiple logs directly to efs caused the slow down
Related
Fatal error: Can't use function return value in write on line 3
I've looked extensively for an answer to my specific situation with no progress. Please review what I've already tried and I've included my VPS global php.ini file. No php.ini files exist within the website root.
<?php
session_start();
?>
<!DOCTYPE html>
<html>
I have no idea how that's possible. Please check out what I've already done to try to solve the problem.
Problem originated when I was unable to pass variables to another page using
$_SESSION['$example'] variables with no luck. But I'll worry about that next.
VPS System Specs Currently (Servers/Networks Are Not My Strong Area)
Apache 3 on CentOS 6.8
Default PHP Version | 5
PHP 5 Handler | suPHP
Apache suEXEC | off
Apache Ruid2 | off
Default PHP Version (.php files) | 5
PHP 5 Handler | suPHP
Attempted Solutions
Disabled .htaccess
.htaccess contains
***suPHP_ConfigPath /***
Header append Vary User-Agent
Prior to disabling:
Removed All 301 Rewrite Rules as I've read they interfere with
sessions
Disabled Error Documents
Ensure No Whitespaces Following session_start();
Caching
Turned off all caching through WHM (that I'm aware of)
Tested both Firefox and Chrome before and after clearing history/cookies/cache/etc
Deleted CloudFlare service for this domain
Additional Information
I Don't have a php.ini file since I use a VPS (in case anyone was wondering)
I use php on almost every other page.
Here is an example of the first few lines of another page.
<?php
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
//Version 1.75
The above code is just the first few lines but the page executes fine without issue. It should be noted that this is a redirect page following a PayPal payment to my website. This issue is recent and previously it has worked fine.
It should also be noted that I use session_write_close(): session_unset(); and session_destroy(); on appropriate pages to unset all $_SESSION variables and terminate sessions.
Below is a link to the php.ini file as text if that helps. The domain contained in the link is not the domain with the issue. I'm not attempting to be "shifty" about the domain with the issue, I just don't want people using the service when it's not working properly.
Global PHP INI File As Text Document
Anyone who solves this, I owe you!
-Andrew
Solved Accidentally
I solved the issues, but still don't know what was causing the Fatal Error
Fatal error: Can't use function return value in write on line 3
$_SESSION variables didn't pass between pages.
I solved both the Fatal Error issue and the $_SESSION variables problem by doing one thing. For some, this may be standard procedure, but I am self-taught and this did not occur to me. I was making changes to the PHP advanced configuration in WHM and never did not see any changes as a result.
I was banging my head against the wall for two days trying every solution I read in the forums.
Apache Server Restart
I never restarted my Apache Server during this time, both issues were resolved.
While this solution may seem rudimentary or common practice for some, it's easy to overlook. I read at least 30 different forum posts on Stack Overflow and other sites. Not one suggested an Apache Restart as a method to check.
PHP Configuration
I changed my PHP configuration as listed below and my sessions variables were passing.
session.use_cookies = 1
session.use_only_cookies = 1
session.use_trans_sid = 0
Thank you for everyone who took the time to look at this.
Sincerely, Andrew
We are having issues with our staging machine, which is running Magento EE 1.13.1
The problem started happening Tuesday afternoon.
At that time we updated an installed php / mysql application.
On the main magento site, the browser is redirected to the magento install page.
The problem occurs only within the Magento application and is related to sessions – when the error occurs, magento throws a fatal similar to this:
(I created a small test application to try to isolate the problem).
Fatal error: Call to a member function getCode() on a non-object in /var/www/html/app/code/core/Mage/Customer/Model/Session.php on line 71
Call Stack: 0.0002 653728
1. {main}() /var/www/html/t.php:0 0.3013 8153600
2. Mage::getSingleton() /var/www/html/t.php:20 0.3013 8153912
3. Mage::getModel() /var/www/html/app/Mage.php:477 0.3013 8153912
4. Mage_Core_Model_Config->getModelInstance() /var/www/html/app/Mage.php:463 0.3016 8302032
5. Mage_Customer_Model_Session->__construct() /var/www/html/app/code/core/Mage/Core/Model/Config.php:1348
The issue only occurs intermittently, and we can temporarily fix it by stopping and starting the httpd service.
We are running magento ee 1.13.1, php 5.3.3, and httpd 2.2.15
This is happening on a staging machine. Our production machine which has the same system and code on it, it working correctly.
We have tried to turn on/off magento compiling, caching, php apc, changed the php sessions to use the disk rather than /tmp/fs, and changed magento to use the DB for its sessions.
The site fails after several minutes.
There are no errors in the system logs.
Can someone suggest how to debug this?
This turned out to be an issue related to the libxml_disable_entity_loader() function.
The zend framework calls this function libxml_disable_entity_loader(true) and then calls it again with (false).
There is a path through our code that was leaving this set to true.
This setting's scope is not limited to the current php script, but to the current httpd process. I.e. it's sticky, and this prevents php's simplexml_load_file function from loading external files.
I came across this article:
Intermittent simplexml_load_file(): I/O warning on local Joomla site
Which led me discover that libxml_disable_entity_loader is not thread safe, and indeed 'sticky' within httpd processes.
Disable Magento compilation:
$ php -f shell/compiler.php -- disable
Compiler include path disabled
There are three ways in which this can be done:
From Magento admin
Navigate to System → Tools → Compilation page and click on Disable button. Navigate to System → Cache Management screen and use Flush Cache button.
Using SFTP, by editing at includes/config.php file
To disable compilation in Magento, edit includes/config.php. Uncomment the first line and comment out the second:
define('COMPILER_INCLUDE_PATH', dirname(FILE).DIRECTORY_SEPARATOR.'src');
define('COMPILER_COLLECT_PATH', dirname(FILE).DIRECTORY_SEPARATOR.'stat');
Using SSH shell program:
php -f shell/compiler.php -- disable
php -f shell/compiler.php -- clear
I have a DMZ set up with a web server and an application server, both running Ubuntu under gnome (v11.04 on the web server and v11.10 on the application server). session_start() has started hanging on the application server. The code is located on the application server and it does not hang when I access my web site and access the page with the session_start() call on it. It seems that every session_start() has started hanging on the application server although I have no problems with the associated pages when I access them from other computers or across the web. Also I have only just started having this problem on the application server without having made any changes to my php code. Could it be that some buffer has filled up and needs to be cleared?
I tried editing /etc/php5/apache2/php.ini and setting
session.save_path = "/tmp"
/tmp exists.
But I still have the problem. I can stop it hanging by preceding session_start() with session_end() but then it does not execute the remaining PHP or html code in the file.
/var/log/apache2/error.log included the following message:
PHP Notice: A session had already been started - ignoring session_start() in
/var/www/DraculaPgm.php on line 101, referer:
http://MyWebSite.com/ApplicationServer/Dracula.php
Any assistance with this would be greatly appreciated,
Peter.
Update 29-Dec-2012
Thank you to everyone who replied to this question. Unfortunately, I tried all of the suggestions and 'session_start()' still hangs. However, if I leave it for a few minutes, it breaks with the following error message.
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /ApplicationServer/Dracula.php.
Reason: Error reading from remote server
Apache/2.2.17 (Ubuntu) Server at MyWebSite.com Port 80
I have squid installed on the web server. Could this be a problem?
Thanks,
Peter
This sounds like a configuration issue. Make sure that PHP is reporting all errors, i.e., error_reporting(E_ALL) and either display or log all errors. (You might even want to enable display_startup_errors in your php.ini) - reporting all errors may shed light on what's going on. (if you need help you can post any errors that you get from this as an edit) You may want to look at the following as well for troubleshooting the issues with sessions:
When using /dev/random as session entropy file
When page is calling itself with the same session
Alternatively if none of those show anything you may want to read over the bug report at https://bugs.php.net/bug.php?id=28856&edit=1 depending on what version of PHP you are running.
I changed 'session_start()' to the following block.
if(!isset($_SESSION))
{
session_destroy();
session_start();
}
I now do not have the problem. I am hesitant to say that it fixed the problem since it did not seem to fix it right away.
Thank you to everyone for your help,
Peter.
Try changing the permission of the /tmp folder by doing chmod 777 /tmp and check if its working.If its working then change the permission mode to make it more secure
Try checking out this Question I call session_start() the script hangs and nothing happens
And this http://www.projectpier.org/node/1934
"It seems that the session file is opened exclusively. On some
occasions (Windows) I have found that the file lock is not released
properly for whatever reason, therefore causing session_start() to
hang infinitely on any future script executions. My way round this
problem was to use session_set_save_handler() and make sure the write
function used fopen($file, 'w') instead of fopen($file, 'x')"
You can find many others having the same problem and their workarounds if you go through http://php.net/manual/en/function.session-start.php
if(!isset($_SESSION))
{
session_start();
}
Use this at the top of your PHP file!
And for your info: session_destroy() is used to end session.
Before anything else - try another browser!
I just encountered this session_start problem. I checked my tmp folder and everything and I was about to call my hosting-provider until I thought I should try another browser first because it might have to do with session cookies.
I work with chrome, so I tested in IE and found that it was indeed the case: It worked in another browser!
I closed IE ;) - went back to chrome, looked for the cookie (PHP_SESS_ID), deleted it and everything works again!
Well, the good part is - Just like you guys I got to brush up my knowledge of -jay- sessions! ;)
In my Linux server's logs I have this
record nearly every 5 minutes. I
couldn't find the reason for two weeks
and I would be very happy if you can
recommend me a way to diagnose the
problem.
My hosting company insists that the problem is within my codes. I use CakePHP 2.2. But I couldn't find anything that causes this problem.
Records are inside error_log file. I use php
5.3.8 and litespeed. 2012-09-03 16:01:28.399 [INFO]
[95.7.223.91:63814-0#APVH_example.com
connection to [/tmp/lshttpd/
APVH_example.com_Suphp.sock. 781]
on request #151, confirmed, 0,
associated process: 845244, running: 0, error: Connection reset by peer!
See below URL i think solve you problem:
http://www.litespeedtech.com/support/forum/showthread.php?t=6125
Let me know if not solved your problem.
UPDATE
You able to change any PHP settings via .htaccess with the same success. If you want to turn off 'Zend Guard' add following line in .htaccess file.
Code:
php_value zend_optimizer.optimization_level = 0
see below URL:-
http://forums.zend.com/viewtopic.php?f=57&t=7063
http://www.webhostingtalk.com/showthread.php?t=947413
I have my online shop, created with WP Ecommerce getting broken after I moved it to another server. I could be sure that the problem comes from WP Ecommerce because when I disable that plugin. Everything run as expected. This is the exact error message
Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 515 is not allowed to access /tmp owned by uid 0 in /home/mikalu/public_html/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 17
Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /home/mikalu/public_html/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 17
I've tried to turn off safe mode on my php configuration. nothing happens. the error's still there.
I thought it was some kind of permission issue, so I tried to change /tmp permission to 777. Nothing happens. I googled it some more and suspect it might have something to do with fastCGI configuration and stuff. Which I totally don't understand.
My googling result mostly suggest me to consult the web hosting provider or even to move to another host. But in this case, I am the owner of the server (VPS with cPanel/WHM). And I don't have any idea how to solve this kind of problem
Any help would be very much appreciated :)
edit: I'm not so sure of this is really a server issue. Because if it really server configuration issue on session save path. Then the whole wordpress shouldn't be working coz it obviously use some session too. The session problem only come from that particular wp-ecommerce script. That's why I post it here on stackoverflow too.
After your edit, it's more clear why you ask that question. Wordpress itself does not uses PHP session, so it's not causing the issue but those component you're using is using PHP sessions.
The PHP manual normally is a good start to understand safemode and how to disable it: http://php.net/manual/features.safe-mode.php
Additionally you should review your server configuration that it is safe instead. Safe-mode is unsafe. Hopefully your server ain't.