OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby erajabi » Thu Oct 24, 2013 2:51 am

Hi Alec,

So please tell me: Should the server administrator change something from the server side? for instance in the php.ini or something like that?
I want to inform them if something should be changed from their side?

Regards,
Enayat
erajabi
 
Posts: 20
Joined: Thu Sep 05, 2013 8:18 am

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby asmecher » Thu Oct 24, 2013 9:08 am

Hi Enayat,

It's not clear to me yet what, if anything, needs to be changed by the administrator. If you start with my instructions at http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=10232&start=15#p42044, I can walk you through some further debugging.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8342
Joined: Wed Aug 10, 2005 12:56 pm

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby erajabi » Thu Oct 31, 2013 4:35 am

Hi Alec,

Ok, I did as you mentioned. New install of application and new DB have been done! ( the patch has been also applied)
I didn't touch anything in the database, the error comes up when I log in:
DB Error: Duplicate entry 'qqk5es9r49vpg1fao9oek0b5jpus46h657pqjpge' for key 'sessions_pkey'

What is next step?

Regards,
Enayat
erajabi
 
Posts: 20
Joined: Thu Sep 05, 2013 8:18 am

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby erajabi » Thu Oct 31, 2013 7:36 am

Hi Alec,

I have good news. Yesterday I received the php.ini from our server administrator and I created a mirror of application on another server. When facing the error, I tried to tested the forum solutions on the php.ini one by one and realized that the problem is solved if I change session.hash_function = sha256 to session.hash_function = 1 (as my ojs encryption is sha1, it should be changed to 0 if the encryption is md5).

I think the error would be removed if this variable is changed on the real server.

Thanks for your help and support,
Enayat
erajabi
 
Posts: 20
Joined: Thu Sep 05, 2013 8:18 am

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby asmecher » Thu Oct 31, 2013 10:27 am

Hi Enayat,

The standard session hash functions generate session IDs with lengths described at http://stackoverflow.com/questions/12240922/what-is-the-length-of-a-php-session-id-string (typically 27, 32, and 40 characters). If you're using one of the hash extensions in your php.ini, it's possible that a longer ID is being generated, potentially resulting in collisions. If that's the case, you can extend the length of the session_id column of the "sessions" table to suit.

Thanks for staying with this.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8342
Joined: Wed Aug 10, 2005 12:56 pm

Re: DB Error: Duplicate entry 'XXXX' for key 'sessions_pkey'

Postby regoli » Sun Jun 08, 2014 10:33 am

I was struggling with this same issue on a fresh install of OCS 2.3.6 on a Mac Mini Server running Mavericks and Server 3.0.4 (Apache/2.2.26 (Unix) PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y DAV/2, and mySQL 5.5.17).

I kept getting duplicate entries in the sessions table. Each looked like this:

6t98up63ltmo4soeqehe0jgp33hs85ler76t4dhp


I would delete the row from the sessions table, login again. Same exact key above. Which told me that the field width for sessions.session_id was too small (at 40 chars). Once I extended it out to 128 characters, my session IDs stored in the table are no longer truncated and appear like this:

a8193vkaia6ugms26ivea7t8vltm89b6fg2bif2cnjhn64dmcf31i6e7g0fhl8mil7c8qumhparddmb8eskqon13ennggnn61banrc3


My session.hash_function in php.ini is default to sha512, by the way.

I hope this information is helpful to those running into "Duplicate entry" issues in the sessions table!

—michael regoli
regoli
 
Posts: 1
Joined: Sun Jun 08, 2014 10:23 am

Previous

Return to OJS Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 14 guests