Welcome Guest, Not a member yet? Register   Sign In
Session: Error while trying to free lock for ci_session
#1

(This post was last modified: 05-19-2016, 09:01 PM by jcarpenter.)

I have reviewed the other few posts related to this error:

Session: Error while trying to free lock for ci_session

and cannot figure out the problem. Our site isn't even close to taking 5 seconds for page loads, in fact they are typically 500ms. Therefore, any other ideas on how to troubleshoot?

As a followup to this I configured memcached (the session driver we are using) to NOT use file locking. I confirmed this with a phpinfo page. Even after turning off file locking I still get this message.
Reply
#2

Changing php.ini settings won't change anything.
Which CI version are you using? If it's not the latest, upgrade to it.
Reply
#3

(05-20-2016, 02:06 AM)Narf Wrote: Changing php.ini settings won't change anything.
Which CI version are you using? If it's not the latest, upgrade to it.

We are on the latest version, 3.0.6
Reply
#4

(This post was last modified: 05-20-2016, 06:22 PM by consigliere.)

I have the same issue.
Our site is hosted on AWS and we have ELB with 5 servers behind.
Yesterday we upgraded CI on 3.0.6 version.
We are using memcached for handling sessions.
In php.ini session handler is setup for memcached .
When I try to use CI with memcached site is loading forever.
But when I setup CI for using files the site is loading normally but have some weird issues.
For example on one page is fine but when I click on the other I have been logout or even use some previous users which I was logged in.
What should I do to make this work as it is supposed to work.
Thanks
Reply
#5

Someone?
Reply
#6

I have the same issue with the Redis driver and am also using CI 3.06 on AWS Elastic Beanstalk: http://forum.codeigniter.com/thread-64854.html

Session library is autoloaded and I am calling session_write_close where applicable.
Reply
#7

@spojoneze,

maybe someone will eventually provide solution or creators will make this work in next version(s).
This is ridiculous, response time with memcached is 5s - 6s, when move to files (php.ini session handler memcached) response is 100ms..
But with files it just logout users from time to time, sometimes in 10 minutes sometimes after 3 clicks on site...
In CI 2 it worked like a charm with same server configuration.. It is really annoying
Reply
#8

Are you calling session_write_close after you're finished writing session data? It won't fix the error but it will speed pages up considerably.
Reply
#9

(This post was last modified: 05-24-2016, 01:37 PM by consigliere.)

Thanks spjonez,

but I don get it, where to call session_write_close() ?
For example I am having this in MY_Controller in __construct:

PHP Code:
if(isset($this->session->userdata["user_id"])){
    
$data["userdata"] = $this->session->userdata;
        if (
$this->config->item($this->uri->segment(1), "lang_list") !== NULL){
            
$this->current_lang $this->uri->segment(1);
        }
    else{
        
$this->current_lang $this->session->userdata["lang"];
    }

Also I am having some other checks in session or update session variable like this:

PHP Code:
if (isset($this->session->userdata["notifications"]["budget"])) {
    
$notifacations $this->session->userdata["notifications"];
    
$notifacations["budget"] = true;
    
$this->session->set_userdata("notifications"$notifacations);

Where I should put session_write_close() ?
Also my app is heavily depends on AJAX calls.
I tried in __desctruct function of MY_Controller to add session_write_close() but with no success.
Beside this I have on numerous places in app where I do echo like this:
 
PHP Code:
<?php echo $this->session->userdata["lang"];?>
Should I after every operations with sessions to call session_write_close() function?
Reply
#10

(This post was last modified: 05-24-2016, 07:21 PM by spjonez.)

In any controller method after you're finished writing session data. You can still get session data after you've called session_write_close but you can't modify it.

Code:
<?php if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );

class Welcome extends CI_Controller {
    public function index( ) {

        // code that modifies session data

        session_write_close( );

        $this->load->view( 'welcome_message' );
    }
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB