Integrity constraint violation: 1062 Duplicate entry

If you're not sure if it is a bug, otherwise please use our bugtracker.

Integrity constraint violation: 1062 Duplicate entry

Postby motv » Thu Dec 22, 2011 5:50 pm

Hi,

I have a fresh new installed Pimcore 1.4.2 (Build 1500). The very first thing I do is to create a new folder in the asset menu. I fill in the name and then I get an error "Server threw exception - could not perform action". In Firebug I get
<b>Fatal error</b>: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-asset' for key 'PRIMARY'' in C:\...\pimcore\lib\Zend\Db\Statement\Pdo.php:228
.
I tried it with PDO and with mysqli (which I can decide at the beginning of the installation) and serveral new instances. Even when I make an update to Build 1593.

I am on a windows system with Zend Server CE. I tried both MySQL 5.1 and MySQL 5.5, no difference.
I read about optimizing and analysing the database in MySQL, but that didn't solve this.

I really want to use pimcore, but I can't do anything without creating new sites or asset folders.
Hope somebody can help me.
motv
 
Posts: 4
Joined: Thu Dec 22, 2011 5:40 pm

Re: Integrity constraint violation: 1062 Duplicate entry

Postby thomas » Tue Dec 27, 2011 12:30 pm

You probably already have a folder with the name you enter.
The keys need to be unique.
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner
User avatar
thomas
 
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany

Re: Integrity constraint violation: 1062 Duplicate entry

Postby motv » Tue Jan 10, 2012 11:36 am

No.
Like I said, I use a totaly fresh new just installed pimcore system.
The error already occurs at the first attempt to create a folder.
motv
 
Posts: 4
Joined: Thu Dec 22, 2011 5:40 pm

Re: Integrity constraint violation: 1062 Duplicate entry

Postby brusch » Tue Jan 10, 2012 10:08 pm

Hi,

That's stange. What is the content of the asset table?

lg, Bernie
User avatar
brusch
Core Team
 
Posts: 358
Joined: Sat Jul 16, 2011 5:37 pm
Location: Salzburg, AT

Re: Integrity constraint violation: 1062 Duplicate entry

Postby motv » Thu Jan 12, 2012 1:42 pm

So, I installed a completely new Zend and MySQL Server and with that it worked at the beginning. It was possible to create new asset folders and new document pages. But after an hour of creating my documents, setting properties and a few times saving and publishing the error occurs again.
I didn't do anything complicated or problematic, just the normal document editing.
Now the error occurs again everytime I publish a document or create a new one. Clicking on 'Only save new version' works and is no problem.

My document table looks totaly normal. Every page has a different ID and also the other fields are looking fine.

The maintenance script didn't change anything.

What can I do to solve the problem or to figure out what causes it?

PS: Just to mention it, I am on a windows machine.
motv
 
Posts: 4
Joined: Thu Dec 22, 2011 5:40 pm

Re: Integrity constraint violation: 1062 Duplicate entry

Postby motv » Thu Jan 12, 2012 5:11 pm

Ok, this is what I found out:

I tried to debug all this stuff and the 'Integrity constraint violation' comes from 3 MySQL Insert Queries.
The first is
Code: Select all
INSERT INTO `documents` (`type`, `id`, `parentId`, `key`, `path`, `index`, `published`, `creationDate`, `modificationDate`, `userOwner`, `userModification`, `locked`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

The second is the same but with 'document_page'. And the third is
Code: Select all
INSERT INTO `search_backend_data` (`id`, `fullpath`, `maintype`, `type`, `subtype`, `published`, `creationdate`, `modificationdate`, `userowner`, `usermodification`, `data`, `localizeddata`, `fieldcollectiondata`, `properties`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


All these inserts get called because of the same behavior: A try-catch-block in which an insert is tried and if that produces an error, the update method is called.
The first two are called in \pimcore\models\Document\Page\Resource.php at line 122 where a comment tells me, that this is necessary because of the recyclebin.
The 3. one is called in \pimcore\modules\searchadmin\models\Search\Backend\Data\Resource.php at line 53.

When I remove the try-catch blocks and only call the update methods, no error message is shown and everything seems to be ok (for now).
motv
 
Posts: 4
Joined: Thu Dec 22, 2011 5:40 pm

Re: Integrity constraint violation: 1062 Duplicate entry

Postby HolgerEvers » Tue Feb 21, 2012 11:40 am

A debug message is created all the time (pimcore 1.4.2) - at least with memcached:

2012-02-21T10:02:06+01:00 DEBUG (7): Pimcore_Resource_Mysql::errorHandler() [173]: [Exception] with message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'pimcore_object_properties_303-properties' for key 'PRIMARY'
In file: /var/www/html/pimcore/lib/Zend/Db/Statement/Pdo.php on line 234
#0 /var/www/html/pimcore/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/html/pimcore/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 /var/www/html/pimcore/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#3 /var/www/html/pimcore/lib/Zend/Db/Adapter/Abstract.php(575): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#4 [internal function]: Zend_Db_Adapter_Abstract->insert('cache_tags', Array)
#5 /var/www/html/pimcore/lib/Pimcore/Resource/Wrapper.php(70): call_user_func_array(Array, Array)
#6 /var/www/html/pimcore/lib/Pimcore/Resource/Wrapper.php(56): Pimcore_Resource_Wrapper->callResourceMethod('insert', Array)
#7 [internal function]: Pimcore_Resource_Wrapper->__call('insert', Array)
#8 /var/www/html/pimcore/lib/Pimcore/Cache/Backend/Memcached.php(91): Pimcore_Resource_Wrapper->insert('cache_tags', Array)
#9 /var/www/html/pimcore/lib/Pimcore/Cache/Backend/Memcached.php(169): Pimcore_Cache_Backend_Memcached->saveTags('pimcore_object_...', Array)
#10 /var/www/html/pimcore/lib/Zend/Cache/Core.php(389): Pimcore_Cache_Backend_Memcached->save('s:6:"a:0:{}";', 'pimcore_object_...', Array, false)
#11 /var/www/html/pimcore/lib/Pimcore/Model/Cache.php(236): Zend_Cache_Core->save('a:0:{}', 'pimcore_object_...', Array)
#12 [internal function]: Pimcore_Model_Cache::storeToCache(Array, 'object_properti...', Array)
#13 /var/www/html/pimcore/lib/Pimcore/Model/Cache.php(289): forward_static_call_array(Array, Array)
#14 /var/www/html/pimcore/lib/Pimcore.php(732): Pimcore_Model_Cache::write()
#15 [internal function]: Pimcore::shutdown()
#16 {main}
2012-02-21T10:02:06+01:00 DEBUG (7): Pimcore_Model_Cache::storeToCache() [241]: Added pimcore_object_properties_303 to cache
HolgerEvers
 
Posts: 105
Joined: Tue Jul 26, 2011 5:46 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest