Forums / General Questions / 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

Locked

Started by dharma on 23 Jan 2007, 9:56 PM · Views: 1,868

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
23 Jan 2007, 9:56 PM
#1
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

Hello,

I have had this error twice today:

1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1
in:
[db_cache table]

since my fresh install of 1.3.7 (yesterday) I have been moving products around and deleting the default products quickly. I also moved my cart to the root this morning, but made sure my paths and configs were correct + ran a fix key cache

The error message pops up, I do a page refresh and its gone, Perhaps its from all the admin activity/product movement deletes?

maybe its nothing, but since this cart is only 24 hours old, I thought I would check to see if there is a bigger issue lurking...

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

14 Mar 2007, 10:48 AM
#2
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

Re: 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

dharma:

I have had this error twice today:

1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1

I've just been looking at this myself.

I think that this is casued by the following process:

  • Visitor 1 views a page, which causes a query to be run. That query is not in the cache so ZC runs the query then caches it for future use.
  • Visitor 2 views the same page, after Visitor 1 but before the result from Visitor 1 has been stored. It sees no result, runs the query, then tries to store it. By this time the results of Visitor 1 have been stored, resulting in a duplicate entry and this error.

If I am right, then the simplest solution is to change the sql_cache_store() function in ~/includes/classes/cache.php, so that

insert into 

becomes

replace into 

or maybe

insert ignore into 

"Replace" would cause the second query to replace the first if it existed. "insert ignore" would just ignore the second query without error. The first sounds better (in that the most recent result is probably the best one to store), but the second would perform better under load and its unlikely that there'd be a change in the results at this point anyway, and if there were then giving the visitor the old data is better than giving the 1062 error.

So, I'm trialling the latter option, but by its nature its hard to test so feedback welcome.

14 Mar 2007, 11:40 PM
#3
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

I tried this suggestion:

http://www.zen-cart.com/forum/showthread.php?t=58002

so far, I have not seen the issue repeat, but my site is not live or been in too much use, so I can't say for sure if it helped/corrected the issue.:lookaroun

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

15 Mar 2007, 8:43 AM
#4
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

Re: 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

dharma:

I tried this suggestion:

http://www.zen-cart.com/forum/showthread.php?t=58002

so far, I have not seen the issue repeat, but my site is not live or been in too much use, so I can't say for sure if it helped/corrected the issue.:lookaroun

That should definitely work: it just removes the functionality rather than attempting to fix it.

12 Apr 2007, 12:55 AM
#5
cjjune avatar

cjjune

Zen Follower

Join Date:
Apr 2007
Posts:
139
Plugin Contributions:
0

Re: 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

My error seem to happen when I execute a job concurently. I tested using 2 browser and click 2 from different browser action at the same time. By deleting the content in db_cache is not a permanent solution. Any one with better solutions? Dr Byte??

12 Apr 2007, 8:04 AM
#6
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

Re: 1062 Duplicate entry 'zc_cc21d2f64edffccfe06d12dd3327bf64' for key 1........

CJJUNE:

My error seem to happen when I execute a job concurently. I tested using 2 browser and click 2 from different browser action at the same time. By deleting the content in db_cache is not a permanent solution. Any one with better solutions? Dr Byte??

Did you try my hack above? That should solve the problem, but needs testing - sounds like you have the ideal environment to test.