Forums / Bug Reports / [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

[Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

Views: 6,620

Results 1 to 20 of 34
9 Dec 2014, 7:25 PM
#1
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

[Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I upgraded from 1.3.x to 1.5.3 and now we have the occasional customer every day who gets a white screen at checkout stating there was a fatal error. That usually ends the online purchase process.

We have few mods installed since the upgrade is recent:
simple analytics, google trusted stores, sitemap xml, rss feed, image handler, fedex, usps and paypal

I see others have the same issue and no where do I see a solution. Surely this is not the accepted state of operation. What can I do to resolve this?

Tom

[09-Dec-2014 04:07:50] PHP Fatal error:  1062:Duplicate entry 'zc_d6616cb5f4c2cb55d422ea67feb723b0' for key 'PRIMARY' :: insert into db_cache set cache_entry_name = 'zc_d6616cb5f4c2cb55d422ea67feb723b0',
                                                 cache_data = 'data deleted',
                   cache_entry_created = '1418126870' ==> (as called by) /var/www/html/www.xxx.com/xxx/store/includes/classes/cache.php on line 131 <== in /var/www/html/www.xxx.com/xxx/store/includes/classes/db/mysql/query_factory.php on line 155
10 Dec 2014, 5:25 AM
#3
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

Thanks, I'll make the change. I appreciate it.
Tom

10 Dec 2014, 9:53 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

tomarriola:

Thanks, I'll make the change. I appreciate it.
Tom

Welcome, as uu have possibly read in that thread (as well there is another with a similar suggestion), this is what has been called a race condition. Basically a request or record already exists and then another similar request is made before the previous has completely finished.

There is a second suggested solution using the mysql replace into command instead of both the insert ignore into and update commands. This looks simplified and compact, but there is some concern about the operations of the replace command that it deletes and inserts routinely as compared to insert and update. Perhaps with more data of comparison the choice can be settled. :) I've had them both in place with no repeated occurrence of the duplicate key issue.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

10 Dec 2014, 2:26 PM
#5
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I can say that after applying the the insert/ignore edits, I went 10 days without seeing any generation of the MyDebug file

For the last 4 days, the same 100Kb MyDebug file (1062 Duplicate entry) has been generated at least once per day.

Rick
RixStix (dot) com
aka: ChainWeavers (dot) com

10 Dec 2014, 2:58 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

Do you have any idea as to whether the customer's IP address was IPv4 or IPv6? (a shot in the dark)

10 Dec 2014, 3:23 PM
#7
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I did look at the server log for this morning and during the timeframe the file was generated there were only 2 lines during that timestamp.4 lines if you include a few minutes before and after, so it was not what I would call a very busy time.

I did notice that there is no specific URL associated with the GET

157.55.39.141 - - [10/Dec/2014:03:07:17 -0800] "GET /index.php?cpath=2_16&sort=20a&page=2 HTTP/1.1" 200 7383 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
[B]110.93.14.68 - - [10/Dec/2014:03:09:48 -0800] "GET / HTTP/1.1" 200 91 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
110.93.14.68 - - [10/Dec/2014:03:09:48 -0800] "GET / HTTP/1.1" 200 7574 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"[/B]
157.55.39.19 - - [10/Dec/2014:03:16:38 -0800] "GET /index.php?cPath=4_52_143&products_id=796 HTTP/1.1" 200 8792 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"

Rick
RixStix (dot) com
aka: ChainWeavers (dot) com

10 Dec 2014, 3:52 PM
#8
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

On Dec 08, the MyDebug file was generated 3 times during the same timestamp. There was something different. Every other occurance of the MyDebug have been identical. 2 of the files were the same, 100Kb files. The middle one was different, 20Kb, though same 1062 error

Server logfile only has 130 lines for that timestamp which doesn't seem overly busy.

Rick
RixStix (dot) com
aka: ChainWeavers (dot) com

10 Dec 2014, 8:05 PM
#9
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I am appalled that zencart is not fixing the PHP Fatal error: 1062 issue. The fixes offered by users do not solve the issue.

All of us using zencart 1.5.x have errors in our /logs/ but most of us don't know they are there. Check your zencart logs and you'll see errors like below:

[10-Dec-2014 09:32:35] PHP Fatal error:  1062:Duplicate entry 'zc_d6616cb5f4c2cb55d422ea67feb723b0' for key 'PRIMARY' :: insert into db_cache set cache_entry_name = 'zc_d6616cb5f4c2cb55d422ea67feb723b0',

This error means your customer got a white screen saying there was a fatal error. This means the money spent to get the customer was wasted because some people find a fatal error scary when they visit a commerce site.

I need to sell things and if zencart isn't helping me do this it must be fixed. Is this a financial issue? I have donated to zencart before but if a direct payment to someone would fix this I would be happy to pay in order to use zencart to sell things rather than deliver fatal error messages to paying customers.

I have been using zencart since version 1 but this is enough to make me finally switch to a commercial tool. Can you imagine volusion shrugging their shoulders at a fatal error. No-- I suspect they'd sit down and fix it.

Consider me outraged.

Tom Arriola

10 Dec 2014, 8:09 PM
#10
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I applied the fix and the errors remain. This is why people use commercial software rather than open source. A commercial tool would be fixed when the first sign of trouble reared its head. We need to wait for someone more clever than ourselves to fix this. And wait. And wait.

I am a long time zen user who may have finally reached the end of his patience with zencart.

Tom

10 Dec 2014, 8:12 PM
#11
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

It appears everyone's zencart 1.5.x isn't fully functional due to PHP Fatal error: 1062

Is there a way to downgrade to a working version of zencart-- like version 1.3.9?

Tom

10 Dec 2014, 8:20 PM
#12
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

tomarriola:

It appears everyone's zencart 1.5.x isn't fully functional due to PHP Fatal error: 1062

Is there a way to downgrade to a working version of zencart-- like version 1.3.9?

Tom

How did you get to this conclusion ??
I do not have any problems with 1.5.x

10 Dec 2014, 8:20 PM
#13
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I encourage you to look at your log files to see how many customers got a white fatal error screen. I have attached a screen dump of mine.

This is not right.
Attachment 14765

Tom

10 Dec 2014, 8:23 PM
#14
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

I have no problems with zencart either. My customers have the problem. Every now and then they get a fatal error screen.

I didn't know this until I ran thru checkout and then I viewed zencart logs to locate the issue. Upon researching it-- I learned the issue is prevalent and not unique to me at all.

Tom

10 Dec 2014, 8:32 PM
#15
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

If PHP Fatal error: 1062 is going to persist-- could we get a better error screen than a white screen with fatal error message on it in plain text? Something informative and informational might save sales?

Tom

10 Dec 2014, 8:46 PM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

mc12345678:

See: http://www.zen-cart.com/showthread.php?205681-1062-Duplicate-entry-for-key-1-in-db_cache&p=1265611#post1265611
The "fix" in that post deals with sessions, not caching.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Dec 2014, 8:47 PM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

Well, following the little threads related to this issue some more, it looks like the function sql_cache_store is subject to the same potential race condition as identified in that other post. My apologies for not picking up on the difference of code section(s) between the two. The error message originally reported dealt with sql_cache_store, where the suggested fix was in the sessions file of a different function. That said it appears that the same fix could be applied here if it hasn't already.

case 'database':
$result_serialize = $db->prepare_input(base64_encode(serialize($zf_result_array)));
$sql = "insert ignore into " . TABLE_DB_CACHE . " (cache_entry_name, cache_data, cache_entry_created) values
  ('" . $zp_cache_name . "', '" . $result_seialize . "', '" . time() . "')";
$db->Execute($sql);

$sql = "update " . TABLE_DB_CACHE . " set cache_entry_name = '" .$zp_cache_name . "',
     cache_data = '" . $result_seialize . "',
    cache_entry_created = '" . time() . "'";
$db->Execute($sql);
return true;
break;

With the above code to replace the case statement for database entirely (assuming that I typed it 100% correctly.

Again, sorry for the slight misdirection, though perhaps solved two problems in one thread?! :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

10 Dec 2014, 8:48 PM
#18
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

tomarriola:

I upgraded from 1.3.x to 1.5.3 and now we have the occasional customer every day who gets a white screen at checkout stating there was a fatal error. That usually ends the online purchase process.

We have few mods installed since the upgrade is recent:
simple analytics, google trusted stores, sitemap xml, rss feed, image handler, fedex, usps and paypal

I see others have the same issue and no where do I see a solution. Surely this is not the accepted state of operation. What can I do to resolve this?

Tom

[09-Dec-2014 04:07:50] PHP Fatal error: 1062:Duplicate entry 'zc_d6616cb5f4c2cb55d422ea67feb723b0' for key 'PRIMARY' :: insert into db_cache set cache_entry_name = 'zc_d6616cb5f4c2cb55d422ea67feb723b0',
cache_data = 'data deleted',
cache_entry_created = '1418126870' ==> (as called by) /var/www/html/www.xxx.com/xxx/store/includes/classes/cache.php on line 131 <== in /var/www/html/www.xxx.com/xxx/store/includes/classes/db/mysql/query_factory.php on line 155

If your site has a damaged cache system, the first step would be to disable the cache so that the error is not triggered ... until such a time as you can resolve whatever is the root cause unique to your specific site.

In /includes/configure.php simply set this to 'none':

define('SQL_CACHE_METHOD', 'none');

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Dec 2014, 8:49 PM
#19
tomarriola avatar

tomarriola

Zen Follower

Join Date:
Oct 2004
Posts:
206
Plugin Contributions:
0

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

OK, thanks for the information. Obviously this raises the question: what is the permanent caching fix? How does caching even get broken?

Tom

10 Dec 2014, 8:51 PM
#20
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] What is the answer to PHP Fatal error: 1062:Duplicate entry

tomarriola:

Obviously this raises the question: what is the permanent caching fix?It really depends on what's broken on your site. Hundreds of thousands of sites are running fine.
tomarriola:

How does caching even get broken?
Hard to say, since I've never had it break on my sites.

This is where I'd recommend you start: http://www.zen-cart.com/wiki/index.php/Troubleshoot_-_Diagnosing_Obscure_Issues

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.