OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



DB Error: Duplicate entry 'xxxx' 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 'xxxx' for key 1

Postby strangelove » Wed Mar 05, 2008 8:34 am

Installing OJS is much more complicated than I had anticipated, but I think with a little more help I will have my http://www.iipj.org/ojs site running. Things worked fine last night. Log on today and do some trial login and log off and I am back to the error:
DB Error: Duplicate entry 'kmtn98ef8p478fdt16homi7mb1' for key 1

What seemed to precipitate this error this am was my LOGGING OFF and attempting to LOG BACK ON. [EDIT] Note that AT TIMES it is impossible to get into the site at all, while at other times one can get in but not log on -- does this suggest a cache or cookie issue?

Alec's first suggestion to this problem is to flush the session with this SQL command: DELETE * FROM sessions;

Now, I hate to be the noob or the newbie, but I am very new to DB work so I am having trouble divining where to enter the command in MyPHPAdmin. I tried using the SQL tab, which leads to "RUN SQL query on databse ojs:" panel, and entered exactly: DELETE * FROM sessions

This delivers the error message:

SQL query:
DELETE * FROM sessions
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM sessions' at line 1


So my syntax is wrong or I am in the wrong panel/function area of myphpadmin. I am in need of more guidance as to how or where to enter the DELETE * FROM sessions; command via myphpadmin.

I do my best to solve these issues before coming to this forum, but here I am stumped. I know Alec et al must be fairly overwhelmed with all the support issues that arise and am grateful for whatever help may be forthcoming.

    NOTE: I was able to set up certain features and enter text and a notice into iipj.org/ojs BEFORE this DB Error: Duplicate entry problem.

    NOTE: There is no line or word pertaining to session.auto_start option in my config.inc.php file -- A PROBLEM HERE? SHOULD THERE BE?

    NOTE: I am using the services of a web site hosting company (blacksun.ca) so I am not certain that I have access to the ability to "restart your IIS/Apache after changing the php.ini file" -- ALSO NOTE: I cannot locate a php.ini in /web/ojs/

I may be in over my head here, but I think I may also be quite close to having a working OJS system.

Thank you for your time and attention,

Dr. Strangelove
University of Ottawa
Last edited by strangelove on Wed Mar 05, 2008 5:18 pm, edited 1 time in total.
strangelove
 
Posts: 14
Joined: Sun Mar 02, 2008 8:27 am

Re: o Flush Sessions Table Using MyphpAdmin

Postby asmecher » Wed Mar 05, 2008 10:14 am

Hi Dr. Strangelove,

Sorry, that's my typo in the SQL command I gave you to run. Use...
Code: Select all
DELETE FROM sessions;
As for the session.auto_start option, that appears in PHP's php.ini configuration file, not OJS's config.inc.php configuration file.

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

Re: o Flush Sessions Table Using MyphpAdmin

Postby strangelove » Wed Mar 05, 2008 2:35 pm

Thank you Alec,

I successfully flushed the tables and received a confirmation "deleted 10 rows".

This had no immediate effect, even after clearing my browser caches (just in case).

My next action was to TURN OFF the config.php setting for: force_login_ssl and set it to force_login_ssl = Off

This appears to have fixed the issue -- I can now move between sections, make content and admin setting changes, login in and out with no DB error.

I am sorry if I overlooked any initial instructions re: force_login_ssl I suspect that ssl login would be a better, more secure setting (??) but until I figure out why this issue (which seemed to effect IE and Firefox browsers more or less equally) remains ...

NOTE that related (?) config.php settings are:

    cache = file

    ; Enable memcache support
    memcache_hostname = localhost
    memcache_port = 11211

    and
    session_cookie_name = OJSSID 9Is this a possible issue re force ssl login ??)/

Now that the OJS system appears stable in my setup I can proceed with cleaning up the look, but I'll start another thread for the issue of the mess on my front page athttp://www.iipj.org/ojs

Thank you kindly for your helpfulness.

Dr. Strangelove
strangelove
 
Posts: 14
Joined: Sun Mar 02, 2008 8:27 am

DB Error: Duplicate entry 'xxxxxx' for key 1

Postby strangelove » Wed Mar 05, 2008 5:17 pm

Update: Reoccurring "DB Error: Duplicate entry 'xxxxxx' for key 1

Re: http://www.iipj.org/ojs

While, regardless of correctly flushing the session table (see above post), this problem remains, although it occurs intermittently. I can made some changes as admin, login, logoff, then BOOM, I get locked out by the "Duplicate entry" error message. Clearing my browser cache has no effect. Flushing the session table has no effect.

The annoying part about this issue is that it is intermittent.

I have renamed this thread to reflect the core issue of the "Duplicate entry" error message and will continue herein until the solution is found and posted here.

-- Michael
strangelove
 
Posts: 14
Joined: Sun Mar 02, 2008 8:27 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby strangelove » Wed Mar 05, 2008 10:04 pm

    Update:

    While the "DB Error: Duplicate entry" problem remains intermittent and unresolved at http://www.iipj.org/ojs it should be noted by those following this thread that a similar problem is manifested within my Joomla CMS system, which runs off a separate database but on the same provider's server (apache, I think) at blacksun.ca. The problem manifested within Joomla is not an exact parallel -- there the error returned is "Invalid Token" and it often takes repeated attempts before I can access a given section with the admin panel. Joomla frequently requires me to login again simply when moving from page to page within the Joomla admin panels and often fails to 'take' the login info as valid (Iknow this is nobody's issue or 'problem' herein -- just thinking through this issue -- I am trying to get some resolution on this problem from within the Joomla forum). Whatever causes this failure within Joomla's admin panel, it does not effect the users experience of the web site which Joomla edits as a CMS platform -- it is strictly internal to the use of Joomla. Whereas with OJS, the DB Error: Duplicate Entry issue is experienced at any point within the /web/ojs site, either as user or an admin.

    In summary: it should also be noted that whereas the OJS system at http://www.iipj.org/ojs tends to fail at any point (whether as a normal user or as an admin), the Joomla-supported front end (http://www.iipj.org) ONLY fails when I am within Joomla's admin panel.

Nonetheless, I am very grateful for the existence of OJS !!

Michael

PS, try the nifty little link at in the top menu of http://www.iipj.org that pops you into the OJS version of the site.
strangelove
 
Posts: 14
Joined: Sun Mar 02, 2008 8:27 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby asmecher » Thu Mar 06, 2008 12:00 am

Hi Michael,

If possible, I'd suggest checking the server logs to see if there are any PHP error messages to help clarify the intermittent problems you're having. If you don't have access to the server log, try inserting the following just below the <?php line of index.php:
Code: Select all
ini_set('display_errors', E_ALL);
This will cause error messages to be shown on the screen. (However, there are some types of messages this will not work for, like memory_limit errors and segmentation faults due to Zend Optimizer, so I'd suggest checking the logs if possible.)

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

DB Error: Duplicate entry '6' for key 2

Postby Pat » Wed Apr 30, 2008 6:12 am

Hello
we have recently installed and started to use OJS for our scientific journal.
After successful publishing of Vol 1, Number 1 we are now preparing Number 2.
In the "Create Issue" section, pon hitting the "save" button I get the error message

DB Error: Duplicate entry '6' for key 2

and can not proceed further.
Logging out, and reentering, flushing the caches does not help.
I am not a database guy and have little knowledge in MySQL administration.
Is there some way to clean up the database from the OJS interface, like
"check consistency", "make consistent". This would be very useful.
Or is there another trap I have run into ?
I have checked all the earlier posts to similar issues but am not really helped because the
OJS installation is hosted elsewhere.
Thanks for help
Pat
 
Posts: 12
Joined: Tue Mar 04, 2008 1:59 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby smiri » Thu May 01, 2008 11:28 pm

Hi Pat,

In your config.inc.php file, please set "debug = On" and "show_stacktrace = On". This way you can see exactly which DB command is failing and it'll be easier to debug from there.

Regards,
smiri
 
Posts: 183
Joined: Thu Sep 06, 2007 7:01 pm

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby Pat » Fri May 02, 2008 4:01 am

Hi smiri

here the debug output. What is wrong upon creating a new issue ?
Thanks for the help
Pat

(mysql): INSERT INTO issues (journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open_access_date, public_issue_id, show_volume, show_number, show_year, show_title, style_file_name, original_style_file_name) VALUES ('6', '1', '2', '2008', 0, 0, null, null, '2', '2008-05-02 00:00:00', '', '1', '1', '1', 0, NULL, NULL)

1062: Duplicate entry '6' for key 2
adodb_mysql._execute(INSERT INTO issues
(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open...) % line 845, file: adodb.inc.php
adodb_mysql.execute(INSERT INTO issues
(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open..., Array[14]) % line 175, file: DAO.inc.php
issuedao.update(INSERT INTO issues
(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open..., Array[14]) % line 252, file: IssueDAO.inc.php
issuedao.insertissue(Object:issue) % line 348, file: IssueForm.inc.php
issueform.execute() % line 136, file: IssueManagementHandler.inc.php

DB Error: Duplicate entry '6' for key 2
Stack Trace:
File: /home/journal/classes/issue/IssueDAO.inc.php line 252
Function: issuedao->update("INSERT INTO issues (journal_id, volume, number, year, publis...", Array(14))

File: /home/journal/classes/issue/form/IssueForm.inc.php line 348
Function: issuedao->insertissue(Object(issue))

File: /home/journal/pages/editor/IssueManagementHandler.inc.php line 136
Function: issueform->execute()

File: /home/journal/pages/editor/EditorHandler.inc.php line 468
Function: issuemanagementhandler::saveissue()

File: (unknown) line (unknown)
Function: editorhandler::saveissue(Array(0))

File: /home/journal/index.php line 58
Function: call_user_func(Array(2), Array(0))

File: /home/journal/index.php line 69
Function: handlerequest()

smiri wrote:Hi Pat,
In your config.inc.php file, please set "debug = On" and "show_stacktrace = On". This way you can see exactly which DB command is failing and it'll be easier to debug from there.
Regards,
Pat
 
Posts: 12
Joined: Tue Mar 04, 2008 1:59 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby asmecher » Fri May 02, 2008 9:24 am

Hi Pat,

There was a bug in the DB index creation for OJS 2.2; you'll need to do one of two things:

1. Make sure you use a globally unique value for the custom issue identifier, or
2. Re-create the index by running the following statements in MySQL:
ALTER TABLE issues DROP INDEX issues_public_issue_id;
CREATE UNIQUE INDEX issues_public_issue_id ON issues (public_issue_id, journal_id);

Let me know how this works.

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

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby Pat » Tue May 06, 2008 8:16 am

Thanks for the help, Alec, it works now.
Do you catch an empty public issue ID now to prevent such errors in the future ?
Greetings
Pat
Pat
 
Posts: 12
Joined: Tue Mar 04, 2008 1:59 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby asmecher » Tue May 06, 2008 9:18 am

Hi Pat,

Yes, future releases will not need this index change and will catch blank IDs.

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

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby sorinp » Wed May 14, 2008 7:51 am

I encountered the same error while tryng to create a new issue: DB Error: Duplicate entry '2' for key 2
I tried to follow your advice gave before to other user and run (mechanic as I am not a familiar with mysql language, but i made a backup copy of the data base first) the sql command:

ALTER TABLE issues DROP INDEX issues_public_issue_id;# Linii afectate: 1
CREATE UNIQUE INDEX issues_public_issue_id ON issues (public_issue_id, journal_id);# Linii afectate: 1

As the problem isn't solved I changed the configsys as mentioned an received the following massage: (see below). Any help please?

Sorin

...
(mysql): INSERT INTO issues (journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open_access_date, public_issue_id, show_volume, show_number, show_year, show_title, style_file_name, original_style_file_name) VALUES ('2', '15', '2', '2008', 0, 0, null, null, 1, '2008-05-14 17:33:15', '', 0, 0, 0, '1', NULL, NULL)

1062: Duplicate entry '2' for key 2

adodb_mysql._execute(INSERT INTO issues(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open...) % line 845, file: adodb.inc.php

adodb_mysql.execute(INSERT INTO issues(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open..., Array[14]) % line 175, file: DAO.inc.php
issuedao.update(INSERT INTO issues
(journal_id, volume, number, year, published, current, date_published, date_notified, access_status, open..., Array[14]) % line 252, file: IssueDAO.inc.php
issuedao.insertissue(Object:issue) % line 348, file: IssueForm.inc.php
issueform.execute() % line 136, file: IssueManagementHandler.inc.php

DB Error: Duplicate entry '2' for key 2
Stack Trace:
File: /home/infomed/public_html/ojs-2.2/classes/issue/IssueDAO.inc.php line 252
Function: issuedao->update("INSERT INTO issues (journal_id, volume, number, year, publis...", Array(14))

File: /home/infomed/public_html/ojs-2.2/classes/issue/form/IssueForm.inc.php line 348
Function: issuedao->insertissue(Object(issue))

File: /home/infomed/public_html/ojs-2.2/pages/editor/IssueManagementHandler.inc.php line 136
Function: issueform->execute()

File: /home/infomed/public_html/ojs-2.2/pages/editor/EditorHandler.inc.php line 468
Function: issuemanagementhandler::saveissue()

File: (unknown) line (unknown)
Function: editorhandler::saveissue(Array(0))

File: /home/infomed/public_html/ojs-2.2/index.php line 58
Function: call_user_func(Array(2), Array(0))

File: /home/infomed/public_html/ojs-2.2/index.php line 69
Function: handlerequest()
sorinp
 
Posts: 9
Joined: Tue May 06, 2008 8:10 am

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby asmecher » Thu May 15, 2008 4:30 pm

Sorin, are you using custom issue IDs? Can you try using a different value (i.e. something that's guaranteed not to be used by another issue)?

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

Re: DB Error: Duplicate entry 'xxxx' for key 1

Postby sorinp » Thu May 15, 2008 7:39 pm

asmecher wrote:Sorin, are you using custom issue IDs? Can you try using a different value (i.e. something that's guaranteed not to be used by another issue)?

Regards,
Alec Smecher
Public Knowledge Project Team


Thank you Alec, you have solved my problem (just before I was already to blow up my data base). As I am not going to use DOI I unchek the lines bellow from setup and every thing is OK.
Custom identifiers will be used to identify issues.
Custom identifiers will be used to identify published items.
Custom identifiers will be used to identify supplemental article files.

Anyhow, as this problem could scare new and unexperienced users (like me) I sugest to insert a warning message someware before mysql gives that message which let the user thing that there is a bug with the application.

Thanks again,
Sorin
sorinp
 
Posts: 9
Joined: Tue May 06, 2008 8:10 am

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 9 guests