Open zfbot opened 11 years ago
(Originally posted by: froschdesign on 12/07/12)
Please also add your report in the bugtracker at Github|https://github.com/zendframework/zf2/issues.
This issue was ported from the ZF2 Jira Issue Tracker at http://framework.zend.com/issues/browse/ZF-12485
Known GitHub users mentioned in the original message or comment: @froschdesign
Jira Information
Description
Scenario: Same user, same browser, sends multiple ajax requests to the server at the same time. Requests are being balanced by a load balancer, and sent to multiple servers, with the same database as storage.
Error: "PHP Fatal Error: Exception thrown without a stack frame in Unknown on line 0" - very helpful of course
Issue: The code that finds the session in the database and updates or inserts it is not doing this in one go.
Problem is, that anywhere between the find and insert, other servers might have already inserted that session, resulting this particular request to fail, with a real error message of: Duplicate entry on primary key "$session id".
My solution for the time being was to wrap this up in a database transaction, but all that code there should translate into something like:
and let the adapter(mysql, postgres, oracle, whatever) decide what the best method of inserting or updating is. For example, on mysql, most probably an INSERT () ON DUPLICATE KEY UPDATE would be the best solution.
PS: this is going on in Zend Framework 2 also.