solved cant create galleries duplicate key error

soaringeagle
@soaringeagle
9 years ago
3,304 posts
i get this error creating new galleries
Query Error: Duplicate entry 'gallery_order-108866-0' for key 'PRIMARY'
i read that its possibly a result of it not being set to create sequential keys
i have restored backup databased from 3 separate dates trying to fix it and ran integrity check including repair modules
ive done file system checks

i have not tried deleting that key


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 07/11/16 02:06:05PM
soaringeagle
@soaringeagle
9 years ago
3,304 posts
i deleted keys above 108865
in both gallery_item and gallery_item_key
its now trying to create 108870
i see that in gallery_item but nothing in gallery_item_key
before deleting i had seen 1 in item_key with the gallery title but it would not alow the gallery to be created'
I'm so confused

note 2 images uploaded despite the error message, deleting the db keys may have been a mistake


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 04/05/16 02:16:27PM
michael
@michael
9 years ago
7,773 posts
"duplicate entry" means the system is trying to insert to a key that already exists while the database is set to use it as a primary key. If it already exists then the system should be UPDATEing that entry.

what's happening when that error is triggered. It sounds like the database is a bit out of whack.
soaringeagle
@soaringeagle
9 years ago
3,304 posts
ive had db issues
but..i see the4m incrementing
b4 i deleted the 2 the error showed but the images did too

after i thought what i should do was delete the 1 that said was that it said was duped..but its still incrementing above that
well i think only the key is now

i had a lot of server issues .. this is the last thing we cant figure out


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
this site just didn't load the new..or any stylesheet (except was the blue)


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
michael
@michael
9 years ago
7,773 posts
are you using the latest version of jrGallery? there is a comment in the changelog that reads:
Quote: - Change: Updated to use new System Core provided repair_module event to fix gallery_order
in ver 1.7.0

Not sure if that is related to the issue you're seeing or not, but worth giving the integrity check another go with all the checkboxes checked just in case.

The name of the entry "gallery_order......" infers that the issue is related to the order that has been set for the gallery images and the new requested order can not be set because that order already exists.

Is this happening when you are changing the order of the images in a gallery?
soaringeagle
@soaringeagle
9 years ago
3,304 posts
i haven't tried changing the order just uploading images to old, and new galleries alike
ill try changing the order and see

but you see it is trying to create new of these 108866 its probably at 108876 now. that number increments beyond the last real data, but says its a duplicate

and yes always run the newest everything


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
if you should be able to just drag and drop to reorder them in the edit gallery they do not let me do that


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
in jegallery_item its invremented to 108883
in jrgallery_item_key only 108867
every attempt to add a photo ads 1 to item but not key i will do the whole integrity check..again

actually there was a new update but no didn't fix it
I'm reading all sorts of techy pages on that error but they are all creating the queries tables and indexes by command line and cant for the life of me figure out how to apply any of it to a table that's full of data
all the support ive seen if for newly created tables

wait..found this https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1
its for wordpress but seemed to be the only 1 that might work but cant find any auto increment anything anywhere


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 04/08/16 07:07:27AM
soaringeagle
@soaringeagle
9 years ago
3,304 posts
hmmm might be sleep deprivation talking, but ..if i just drop item but not key
then run integrity check wouldn't it recreate item matching the item and item key numbers/
i dont want to try it till i get an answer
but since item is just a list of item numbers that should match the key ..even if integrity check doesn't fix it wouldn't a simple script be able to be written to just create an item for each key ..then it would auto increment?
(be a lil extra clear in your response haven't slept in 3 days trying to figure this and other issues out)
i have an error in cometchat saying it cant create a table without it being removed 1st...but it was


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
ok I'm real confused now, i renamed all 3 files in MySQL directory
the .frm .MYD and .MYI adding .bak
the table no longer showed in phpmyadmin i ran the integrity check it did not recreate the table
i expected the gallery to not work at all without that table, but it did work, and got the same error with or without the table (and every save click increments the number) how..i don't know after removing .bak i do see the 2 test save numbers in item but nothings created in item_key
and i don't know how it saved it in item with the table files renamed ..hmm unless it saved it in qurery cache ?
i rsynced the db to backup b4 tests to be safe
should i rename them, restart MySQL then do integrity test?
i really cannot understand how the new keys were saved to the db with the files renamed


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
holy %^&*
i fixed it!
ok heres what i had to do
step 1 rename all files related to that table
2 restart MySQL
3 tested it and it incremented as 1 as in the 1st record otr item
then step 4
ran mysqlcheck --check --auto-repair --all-databases
and walla it fixed it

just shows you the power of sleep deprived guesswork


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
oh no!! now it shows just 1 2 and 3 in the db i mean only 3 items i hope its not overwriting old photos with new
back to square 1 i guess thought i had it fixed
started over
no matter what i do it increments it not sequentially by whats in the db just adds 1 each time if last 1 in db ends in 65 it still adds next 1 as 92
but nothings added to the key




--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 04/08/16 03:43:58PM
soaringeagle
@soaringeagle
9 years ago
3,304 posts
damn the more braindead tired i am the smarter i must get
ok final solution
it was incrementing item_id etc
i ran this search in phpmyadmin

SELECT *
FROM `greentec_jam`.`jr_jrgallery_item_key`
WHERE (
CONVERT( `_item_id`
USING utf8 ) LIKE '%gallery_order%'
OR CONVERT( `key`
USING utf8 ) LIKE '%gallery_order%'
OR CONVERT( `index`
USING utf8 ) LIKE '%gallery_order%'
OR CONVERT( `value`
USING utf8 ) LIKE '%gallery_order%'
)
ORDER BY `key` DESC , `_item_id` DESC , `index` DESC
LIMIT 0 , 30
(just search all tables for gallery_order)
there i saw the highest number was 109110
so i went back to gallery_item copied the one numbered 108865 and made it numbered 109111
it since has added a number more (not sure why) but that solved the duplicate order number by making gallery_item increment from there


i had absolutely no idea what i was doing just going on pure instinct and somehow made it work


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

Tags