New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INSERT INTO ci_sessions
- Query error: Duplicate entry for key 'PRIMARY'
#4923
Comments
You've done great with tracking this one down, thanks! |
this problem still exists. You marked it closed but didn't add the fix |
I'm pretty sure it was fixed in this commit: 6276926 And shipped with v3.1.3. |
It was. Something tells me @amerloc has only read the title and has a different problem solvable via RTFM. :) |
No I tried to upgrade one site and it completely broke. Couldn't sign in anymore. when I reverted to my old system file then I was able to login again. Just a note, I was updating from 3.0.6 to 3.1.3. I have managed to get rid of the problem by trace and error lolz |
Well then, what problem did you find? |
Hi @narfbg, We are currently running with CI 3.1.6. While the problem did not present with any desktop browsers. We are using the CI Session with MYSQL database. However, it is very consistent with Google Chrome Mobile (Version 64.0.3282.137). We even tested by removing all the active session entries from MYSQL and use the Google Chrome Mobile to serve the site. Every time we do get the same error as reported in this issue. We tried Firefox Mobile (Version 58.0.2) but the problem did not present. Any idea? Thanks! |
This bug happenned to trigger the same error message from MySQL that you may be getting, but it did so in a very unique way that is otherwise impossible. When MySQL complains about a duplicate primary key in the sessions table, it can only be because of Also, this is a bug tracker and we don't answer support questions here. When you need help, please post on our forums. I am writing this comment only because of the uniquely weird way in which the triggered error messages happen to match, but will otherwise refuse to answer anybody's questions here because it is simply counter-productive - I can't be an assistant to everybody. On the forums, at the very least you can get help from other people who've encountered the issue or can figure it out, and I only have to chip-in on particularly hard problems or where I suspect a legitimate bug - a win-win for everybody. |
Hi @narfbg, Points taken. Thanks! |
Hi,
When writing session data, every so often I get a "Duplicate entry" error. I am using the database driver with MySQL.
I was finally able to figure out reproduction steps. Basically, if the session read fails to obtain the lock (e.g the timeout limit is reached)...
Then
$this->_session_id
is not set, which is needed by write() to detect session_regenerate_id() calls.Then, during the write, this runs:
If the lock is obtained here, then the write doesn't fail, but instead tries to update the session_id (not shown), resulting in the duplicate entry.
Perhaps, if
$this->_get_lock($session_id) === FALSE
in the read, then it should cause a failure?The text was updated successfully, but these errors were encountered: