Closed billystalnaker closed 2 years ago
When two separate processes attempt to add()
at the same time (i.e. because AJAX requests executing at the same time will cause this), one of them will fail. Changing this to set()
means that they just overwrite each other and that's not good.
@narfbg That is the time that we experienced this error, when multiple ajax calls were run one after another. Are you saying that I should slow down my ajax requests?
@billystalnaker Read: https://www.codeigniter.com/user_guide/libraries/sessions.html?#a-note-about-concurrency
Ok, that is helpful. I guess I have to now write code not normally needed when working with codeigniter... That doesn't make sense to me, but I will try to get my org to fund us restructuring things so that I can have 50 session_write_close's in the code now??
Well, that escalated quickly ...
No, I'm not saying you should slow down your AJAX requests and I have not hinted at that in any way. I'm not even saying there's no bug somewhere in here; all I'm saying is that changing that add()
call to set()
will cause different problems.
How you got to the conclusion that now you need extra restructuring, funding and whatever else all because of CI is beyond me.
I believe this guy was having this same issue, but he wasn't aware it was a bug: https://github.com/bcit-ci/CodeIgniter/issues/5543
We've just upgraded our CI framework from 3.1.4 to 3.1.10 and have since been experiencing the same error that he was experiencing. I thought it was an issue with converting to session_locking but now understand that session locking has always been there in Codeigniter as a "virtual" lock. Which is great, I'm glad I can use memcached and still have session locking. However I've found one line of code that seems to cause the issue and reverting it back to what it was on 3.1.4 seems to resolve the error we're experiencing. On line 351 of the Session_memcached_driver.php file there is this line:
if ( ! $this->_memcached->$method($lock_key, time(), 300))
themethod
variable is obvi determined by whether the lock key exists in memcached or not. But it seems that it never exists in memcached at all during my debug session. So I just reverted it to:if ( ! $this->_memcached->set($lock_key, time(), 300))
and all is well again.. Here are my comments in the code hopefully we can resolve this together so I can revert the changes that I've made to the memcached driver file:Please let me know if there are any questions.