DB Error: Duplicate entry ‘NULL’ for key ‘sessions_user_id’
I’m getting the above error on my site. It seems like I can just delete sessions from the sessions table and that will fix things, though I’m not sure if there are any side effects of just running a sql command directly on the db and not going through the admin or something of that sort.
Also, how long will that fix really last (if there are duplicates now, what’s stopping this from happening again in about 2 minutes)
What application and what version are you running?
At least in OJS 2.4-ish, the
sessions_user_id index on the
sessions.user_id field should be marked non-unique, allowing duplicates.
Yeah, sorry, should have included that. It looks like it’s OJS 2.4.6.
When I inspect the index, it describes that as non unique, which is one reason that I was a bit confused on how to move forward with it.
Also, as a follow up on the short term solution, it seems as though someone truncated the sessions table. The site is running, I’m just looking to make sure it’s not a recurring bug.
I found one hit for this on Google, with the following stacktrace:
DB Error: Duplicate entry 'NULL' for key 'sessions_user_id'
File: /mnt/www/sigs/ojs/lib/pkp/classes/session/SessionDAO.inc.php line 75
Function: DAO->update("INSERT INTO sessions (session_id, ip_address, user_agent, cr...", Array(8))
File: /mnt/www/sigs/ojs/lib/pkp/classes/session/SessionManager.inc.php line 82
File: /mnt/www/sigs/ojs/lib/pkp/classes/session/SessionManager.inc.php line 114
Function: SessionManager->SessionManager(Object(SessionDAO), Object(Request))
File: /mnt/www/sigs/ojs/classes/security/Validation.inc.php line 283
File: /mnt/www/sigs/ojs/lib/pkp/classes/core/PKPPageRouter.inc.php line 65
File: /mnt/www/sigs/ojs/lib/pkp/classes/core/Dispatcher.inc.php line 113
File: /mnt/www/sigs/ojs/lib/pkp/classes/core/PKPApplication.inc.php line 180
File: /mnt/www/sigs/ojs/index.php line 65
Without more data, I’d just watch for it to reoccur. If it does, we can dive into the code and database to see what is going on.
Yeah fair enough. I wasn’t sure if there was something obvious that I was missing, but that seems like a reasonable course of action.