• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session: Error while trying to free lock for ci_session

#51
Hi, I'm trying to debug this strange issue.. I can reproduce it with many curl request parallelized with xargs -P, I can't figure out why sometimes a session lock is deleted while is used (when the wrong release occurs, the TTL on the lock key is -2).

A stupid workaround, while I'm digging into code is to randomize the time to wait in Session_redis_driver.php, line 340 instead of:

PHP Code:
sleep(1); 

replace with:

PHP Code:
$sleep_random rand(100000,500000);
usleep(500000+$sleep_random); 


In this way I reduce a lot the "Error while trying to free lock.." occurence, before that i can reproduce the error with 8-12 concurrent request, now I have to raise up to 64 parallel request.

I hope it helps Wink

k.
Reply

#52
I've made a few change to my workaround:

replaced the "sleep(1)" with:
PHP Code:
$sleep_random = (rand(0,5)) * 100000;

usleep(500000+$sleep_random); 


and avoided to delete an unexistant key, replacing:


PHP Code:
if (isset($this->_redis$this->_lock_key) && $this->_lock


with:


PHP Code:
if (isset($this->_redis$this->_lock_key) && $this->_lock && $this->_redis->exists($this->_lock_key)) 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.