By fbomb on
I just upgraded my test drupal install from 4.5 to 4.6 with minimal effort. Now, whenever I try to login, I get (IP substituted):
Fatal error: Duplicate entry 'ea2b42dccc4ec59222fa19b0e7ebad76' for key 1 query: INSERT INTO sessions (sid, uid, hostname, timestamp) VALUES ('ea2b42dccc4ec59222fa19b0e7ebad76', 0, '11.11.111.111', 1114188995) in /home/sites/drupal/includes/database.mysql.inc on line 66
It seems that drupal registers a session when I first visit the front page, but tries to insert the same session upon logging in and each subsequent request after that. I've even deleted the session cookie, cleared the session table, and tried again with the same result. any ideas?
Comments
well, i figured it out
well, i figured it out.....
for some odd reason, the first query in the sess_read function was not returning any results. This was happening because i had no record in the user table with uid=0. I have NFI why that wasn't there, but everything's working now.....
I have uid 0
I have uid 0, but still I have that bug.
The site is http://beta.karelia.buddhism.ru
It happened right after transferring site from my local test server to the production server.
hook_user problems can cause this, too
I was working on a hook_user function to handle delete operations. When I was testing my (broken, at the time) code, I deleted a user, saw my error, and hit reload on my browser. Did that a couple times thinking there was little harm in it.
But actually this deleted all the users in my test system, except uid=1. Then I started to see access denied when logged out, and when I tried to log in, I got the duplicate entry error above.
As fbomb points out, you need to add user 0 to the users table. I did this by copying from drupal's database.mysql file:
Restoring User 0
We just had this happen to our site as well. Restoring user 0 did the trick. However, remember to restore the users_roles values as well or else your anonymous users will be getting "access denied" messages all over the place:
/* EJK */
Deleting Drupal / CiviCRM users caused Fatal error
My CivicSpace 0.84a2 / CivicCRM 1.4 installation experienced this problem shortly after the admin deleted two user records from Drupal & deleted the corresponding records in CiviCRM.
Clearing the sessions table did not work.
Using EJK's INSERT INTO code solved the problem.
Thanks EJK!
Since this is a frequent problem across multiple installation versions, how do we best get this issue documented so that the developers can create a permanent fix?
David
thanks
I just had this problem on an old 4.6 site. This fixed it for me.
INSERT INTO users (uid,
INSERT INTO users (uid, name, mail) VALUES ('0', '', '');
INSERT INTO users_roles (uid, rid) VALUES (0, 1);
Worked for me too :-(
Drupal 4.6
It is working well
I also have a problem like all of you, it is duplicated a key query in Sessions table.
But now it is solved. Thanks for your solution.
INSERT INTO users (uid, name, mail) VALUES ('0', '', '');
INSERT INTO users_roles (uid, rid) VALUES (0, 1);
Drupal 4.6
Thanks,
Hy ChanHan
Deleting user record is the poodles kern
I had the same error after deleting a user, which had not gone neatly either: I had an error message after confirming "Delete User". But - too quick I reloaded he page - only afterwards the
Fatal error: Duplicate entry '6431fadaef2b3263414975e222319b49' for key 1 query: INSERT INTO sessions (sid, uid, hostname, timestamp) VALUES ('6431fadaef2b3263414975e222319b49', 0, '127.0.0.1', 1147203614) in d:\localhost\includes\database.mysql.inc on line 66
ocurred.
Did somebody have that error on deleting the user BEFORE actually not being able to access the page not at all anymore?
Thank you very much for this
Thank you very much for this solution.
I deleted a users record last night and it caused the site to be unavailable to users who were anonymous or were not logged in. The site had been running for almost 3 years without having this problem.
But why?....
Why does user 0 have to exist? Does anyone know?
user 0 is the anonymous, or
user 0 is the anonymous, or not logged in, user. Whether there is a reason the row in the database needs to exist I'm not sure. Clearly the code does not do well when it is missing. And the SQL from the install puts the row in there...
Ok but...
What triggers the error? Been running the site for 4 months and just having problems now. ????
MB
Drupal 4.6.3 with MySQL 4.1/PHP5
I had this problem - found out that it's not inserting the entire session key, hence never matches but generates DUPLICATE KEY errors. I had to alter the 'sid' column in the sessions table to varchar(64) from varchar(32) - this is the safe bet, you could probably alter it to varchar(40) or something, if you want to be exact...
Anyway, that will solve the problem - it's always so simple when you spend ages looking through the code.
To the authors: SELECT * is BAD BAD BAD!
Me too
I seem to have the same problem. How do you change the 'sid' column in the way you mentioned?
Andre
how to change 'sid' column
Access your MySQL database and type the following after the mysql prompt:
Then you can type the following to confirm it's been changed:
I modify
I used these commands and the problem persist :(
Maybe my server has HD wrong, because squid/oops proxy cache died.
I had this problem on my
I had this problem on my machine when I was doing some testing between different browsers. It kind of happened out of the blue, because I usually am logged in with at least two browsers (one as user, one as admin).
Anyway, I could access the site from Firefox, but Safari choked and returned a similiar session error as above.
Your solution worked... I emptied the sessions table and modified sid to be VARCHAR(64).
So far, the problem has not returned.
Thanks for posting this!
This solutions saved my a**! I was on a deadline and a mod I made to the code with a syntax error caused an error which led to this problem. What would have taken hours to track down took minutes to fix. Thanks!
--
Get better help from Drupal's forums and read this.
I still get a blank screen
I ran into this problem while implementing the delete op on civicrm_user. I following all of the steps above yet now I get a blank screen with no source. Does anybody know what might be causing this?
last step -> turn cache support off
I turned this off and I am back in business.