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: 8851
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: 8851
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

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

Postby jessmi » Sun Sep 14, 2014 1:22 am

Hi,

I have the same problem. I tried everything posted in this forum, but still have DB error :(

my php config is here http://www.journalofaccounting.eu/phpinfo.php

can somebody help me to fix it?

thanks
jessmi
 
Posts: 7
Joined: Sat Sep 13, 2014 2:24 am

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

Postby asmecher » Sun Sep 14, 2014 7:27 am

Hi jessmi,

Could you describe specifically which steps you've tried and what the results were?

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

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

Postby jessmi » Sun Sep 14, 2014 10:03 am

Hi Alec,

I tried to disable APC, change the length of sessions_id in DB, also I see some patches, but in my version were all already incorporated, so I do not know, where the problem is.

Michal
jessmi
 
Posts: 7
Joined: Sat Sep 13, 2014 2:24 am

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

Postby asmecher » Sun Sep 14, 2014 3:00 pm

Hi Michal,

Did you check this thread? Could you post the results of your phpinfo() output? What version of OJS are you using?

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

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

Postby jessmi » Sun Sep 14, 2014 10:14 pm

Hi Alec,

I already checked all threads, but nothing work for me. I'm using the latest 2.4.4.1 version.

You can see my full phpinfo() at http://www.journalofaccounting.eu/phpinfo.php

I do not know, which part I should to post.

Michal
jessmi
 
Posts: 7
Joined: Sat Sep 13, 2014 2:24 am

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

Postby asmecher » Mon Sep 15, 2014 8:28 am

Hi Michal,

Your phpinfo output shows APC as enabled.

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

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

Postby jessmi » Mon Sep 15, 2014 10:39 am

Hi Alec,

Now I already disable APC - apc.enabled = off

Michal
jessmi
 
Posts: 7
Joined: Sat Sep 13, 2014 2:24 am

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

Postby asmecher » Mon Sep 15, 2014 10:52 am

Hi Michal,

Your phpinfo() output looks fine at a glance; there must be something non-standard about your environment. Have you made any modifications? If you're handy with PHP, I'd suggest looking into lib/pkp/classes/session/SessionManager.inc.php to see what the full session ID that you're trying to insert looks like; it may be that it's still getting truncated (though the configuration looks normal to me).

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

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

Postby jessmi » Mon Sep 15, 2014 12:45 pm

Hi Alec,

I did not make any midifications. I'm not handy with PHP :( so I do not know, how can I see the full session ID.

Michal
jessmi
 
Posts: 7
Joined: Sat Sep 13, 2014 2:24 am

PreviousNext

Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 3 guests