OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



DB Error: Duplicate entry 'XX...' for key 1

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.

DB Error: Duplicate entry 'XX...' for key 1

Postby segis » Wed Nov 29, 2006 7:35 am

Hello. After changing server and uploading the MySQL database I get the following error when trying to access ojs:
DB Error: Duplicate entry 'f2a3b0b8e3be9fb1e2826' for key 1
OJS: DB Error: Duplicate entry 'f2a3b0b8e3be9fb1e2826' for key 1
Using Microsoft IIS with PHP 5
Can someone help?
Thank you
segis
 
Posts: 5
Joined: Mon Aug 28, 2006 7:48 am

Postby asmecher » Wed Nov 29, 2006 10:59 am

Hi segis,

Try flushing your sessions table:
Code: Select all
DELETE FROM sessions;
Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8426
Joined: Wed Aug 10, 2005 12:56 pm

table sessions

Postby segis » Wed Nov 29, 2006 11:37 am

Thank you.
I flushed the session table. Then I was able to retrieve content from the database once, but in the next call to the database, the same error came up. For instance, I go to "instructions for authors" and it works, but the next time in which the database should be accesed there comes the same error.
The key in the session table seems to be always the same for the same ip, and it does not seem to be deleted when leaving the application.
A potentially relevant observation is that when the session table is empty you cannot login with a valid username, though you can access some pages if you call the database just once.
segis
 
Posts: 5
Joined: Mon Aug 28, 2006 7:48 am

Postby asmecher » Wed Nov 29, 2006 12:39 pm

Hi segis,

This may be caused by the session.auto_start setting; OJS requires that this setting be turned off in your system's php.ini. If that's not the problem, try setting the php.ini setting "display_errors" to E_ALL and the config.inc.php setting "show_stacktrace" to On. Restart your web server and try again; this should generate more useful error output.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8426
Joined: Wed Aug 10, 2005 12:56 pm

Postby segis » Wed Nov 29, 2006 1:23 pm

Thank you again, Alec.
With the show_stacktrace = On (and from another IP) I get the following messages:
DB Error: Duplicate entry '742ed4fba5e6961675dc3' for key 1
Stack Trace:
File: C:\Inetpub\vhosts\revistaneurocirugia.com\httpdocs\ojs21\classes\session\SessionDAO.inc.php line 79
Function: DAO->update("INSERT INTO sessions (session_id, ip_address, user_agent, c...", Array(7))

File: C:\Inetpub\vhosts\revistaneurocirugia.com\httpdocs\ojs21\classes\session\SessionManager.inc.php line 78
Function: SessionDAO->insertSession(Object(Session))

File: C:\Inetpub\vhosts\revistaneurocirugia.com\httpdocs\ojs21\classes\session\SessionManager.inc.php line 105
Function: SessionManager->SessionManager(Object(SessionDAO))

File: C:\Inetpub\vhosts\revistaneurocirugia.com\httpdocs\ojs21\index.php line 38
Function: SessionManager::getManager()

File: C:\Inetpub\vhosts\revistaneurocirugia.com\httpdocs\ojs21\index.php line 57
Function: handleRequest()

OJS: DB Error: Duplicate entry '742ed4fba5e6961675dc3' for key 1
segis
 
Posts: 5
Joined: Mon Aug 28, 2006 7:48 am

Postby asmecher » Wed Nov 29, 2006 2:58 pm

Hi segis,

Looks like you're using OJS 2.1.0; there were several tricky reference bugs corrected in OJS 2.1.1, some of which relate specifically to PHP 5.x. It's possible that you're encountering a bug that's been corrected since then. Could you try upgrading to OJS 2.1.1? There are upgrade instructions in docs/UPGRADE; the upgrade should be painless, but please back up your database and files before trying.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8426
Joined: Wed Aug 10, 2005 12:56 pm

Postby segis » Thu Nov 30, 2006 6:25 am

Thank you very much, Alec.
I did as you suggested and everything seems to be working now.
Best regards
segis
 
Posts: 5
Joined: Mon Aug 28, 2006 7:48 am

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby ramon » Mon Oct 08, 2007 3:22 pm

Alec,

We're running into this problem after installing/moving to another server (stacktrace is On)

Code: Select all
DB Error: Duplicate entry '35usfsh8q8krjmb4o22hcie5o7' for key 1
Stack Trace:
File: /srv/www/htdocs/ojs2/classes/session/SessionDAO.inc.php line 79
Function: DAO->update("INSERT INTO sessions (session_id, ip_address, user_agent, cr...", Array(7))

File: /srv/www/htdocs/ojs2/classes/session/SessionManager.inc.php line 78
Function: SessionDAO->insertSession(Object(Session))

File: /srv/www/htdocs/ojs2/classes/session/SessionManager.inc.php line 105
Function: SessionManager->SessionManager(Object(SessionDAO))

File: /srv/www/htdocs/ojs2/index.php line 38
Function: SessionManager::getManager()

File: /srv/www/htdocs/ojs2/index.php line 57
Function: handleRequest()


PHP Version 5.2.3
Apache 2.0
MySQL 5.0.18

I edited ojs2/index.php and added this:

ini_set('session.auto_start','Off');

Not sure if it's correct.

Any help is appreciated..
ramon
 
Posts: 926
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby asmecher » Tue Oct 09, 2007 11:27 am

Hi Ramón,

Did you try the solution above at http://pkp.sfu.ca/support/forum/viewtopic.php?p=4388#p4388?

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

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby ramon » Tue Oct 09, 2007 1:36 pm

Alec,

Your link is leading to this thread. Is the link correct?
If it is, I did flush the sessions table, and it does work once. After clicking another page, the error is displayed.
I added the session.auto_start directive in ojs2/index.php, but I'm not sure if that's the right place, or if the syntax is correct.
ramon
 
Posts: 926
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby asmecher » Tue Oct 09, 2007 3:38 pm

Hi Ramón,

I'm not sure if the session auto start php.ini directive is configurable via ini_set -- by the time the script gets to the ini_set directive, it's too late and the session has already been created. I suspect you'll have to either modify the server's php.ini or configure an .htaccess override.

One other thing to check -- make sure there is no "auto_prepend_file" configured in php.ini; if there is one, and it works with session data, it might cause the problem.

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

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby jorgeff » Wed Oct 24, 2007 11:27 am

Hi,

After installing OJS 2.1.1 I get the following error (stracktrace on):

DB Error: Duplicate entry '377bc860e1a99da600f5e315b22ebb5d' for key 1
Stack Trace:
File: /var/www/ojs/classes/session/SessionDAO.inc.php line 79
Function: DAO->update("INSERT INTO sessions (session_id, ip_address, user_agent, cr...", Array(7))

File: /var/www/ojs/classes/session/SessionManager.inc.php line 78
Function: SessionDAO->insertSession(Object(Session))

File: /var/www/ojs/classes/session/SessionManager.inc.php line 105
Function: SessionManager->SessionManager(Object(SessionDAO))

File: /var/www/ojs/index.php line 38
Function: SessionManager::getManager()

File: /var/www/ojs/index.php line 57
Function: handleRequest()

If I flush the sessions table it does work once. The session.auto_start is off and there is no auto_prepend file in php.ini, but I get the same error.
My system:
PHP 5.2.3
Apache 1.3.34
MySql 4.1.15

Any idea?

Regards,
Jorge Figueroa
Universidad de Talca
jorgeff
 
Posts: 4
Joined: Wed Oct 24, 2007 10:53 am

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby asmecher » Wed Oct 24, 2007 11:40 am

Hi Jorge,

Odd; have you checked your server log to see if any relevant messages appear, i.e. about the ini_set function being disabled?

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

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby jorgeff » Wed Oct 24, 2007 12:29 pm

Hi Alec,

There is nothing about ini_set. I post my apache and mysql logs.

Here is the Apache log:
[Wed Oct 24 15:52:22 2007] [error] OJS: DB Error: Duplicate entry '377bc860e1a99da600f5e315b22ebb5d' for key 1

(now 377bc860e1a99da600f5e315b22ebb5d -> XX)

and here is the mysql log:

/** I just flushed the sessions table and it works once... */
071024 15:56:31 1459 Init DB ojs
1459 Query SET NAMES 'utf8'
1459 Query SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = 'CounterPlugin' AND journal_id = '0'
1459 Query SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = 'TinyMCEPlugin' AND journal_id = '0'
1459 Query SELECT * FROM sessions WHERE session_id = 'XX'
1459 Query INSERT INTO sessions
(session_id, ip_address, user_agent, created, last_used, remember, data)
VALUES
('XX', 'My_IP', 'My_USER_AGENT', 1193252191, 1193252191, 0, '')
1459 Query SELECT * FROM site
1459 Query SELECT * FROM site
1459 Query SELECT * FROM journals WHERE enabled=1 ORDER BY seq
1459 Query UPDATE sessions
SET
user_id = NULL,
ip_address = 'My_IP',
user_agent = 'My_USER_AGENT',
created = 1193252191,
last_used = 1193252191,
remember = 0,
data = ''
WHERE session_id = 'XX'

/** then I try again and I get the error. */
071024 15:59:56 1475 Connect ojs@localhost on
1475 Init DB ojs
1475 Query SET NAMES 'utf8'
1475 Query SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = 'CounterPlugin' AND journal_id = '0'
1475 Query SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = 'TinyMCEPlugin' AND journal_id = '0'
1475 Query SELECT * FROM sessions WHERE session_id = 'XX'
1475 Query INSERT INTO sessions
(session_id, ip_address, user_agent, created, last_used, remember, data)
VALUES
('XX', 'My_IP', 'My_USER_AGENT', 1193252396, 1193252396, 0, '')
1475 Query UPDATE sessions
SET
user_id = NULL,
ip_address = 'My_IP',
user_agent = 'My_USER_AGENT',
created = 1193252396,
last_used = 1193252396,
remember = 0,
data = ''
WHERE session_id = 'XX'

The last INSERT query try to insert an already existing session_id value (that is a primary key), so it fail.
Is this log useful?

I appreciate your help.

Regards,
Jorge Figueroa
Universidad de Talca
jorgeff
 
Posts: 4
Joined: Wed Oct 24, 2007 10:53 am

Re: DB Error: Duplicate entry 'XX...' for key 1

Postby asmecher » Wed Oct 24, 2007 1:08 pm

Hi Jorge,

Odd; the SELECT * FROM sessions WHERE session_id = 'XX' statement looks for an existing session. The session manager only inserts a new one if it can determine that none exists. I'm having trouble duplicating this on my test machine, and I'm using a similar setup. Would you be willing or able to give me temporary access to the server (e.g. enough to temporarily modify the PHP and flush the sessions table) to investigate further?

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

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 5 guests