Forums / General Questions / [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

[Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

Started by rayw1679 on 6 Feb 2013, 2:02 AM · Views: 10,457

Results 61 to 69 of 69
7 Dec 2014, 6:28 PM
#61
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,816
Plugin Contributions:
4

[Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

I would prefer an INSERT ... ON DUPLICATE KEY ... for MySQL.

Longer syntax, but does performs an UPDATE if the insert fails versus always doing a DELETE + INSERT (if I remember correctly).

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

7 Dec 2014, 6:32 PM
#62
rixstix avatar

rixstix

Totally Zenned

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

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

After 10 days without generating the MyDebug file, I was beginning to think that all was fine though I did not schedule a PCI scan on the first of the month which historically I see the file generated many times during a scan.

Overnight, the 100K MyDebug file was generated.

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

6 Jan 2015, 1:19 AM
#63
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

Just to close the loop here ...
We've opted for ON DUPLICATE KEY UPDATE for ZC v1.6.0:
https://github.com/zencart/zencart/pull/244/files
and
https://github.com/zencart/zencart/pull/245/files

(Text in red is stuff that was removed. Text in green is stuff that was added/changed.
Basically, remove all the lines that are shown as starting with a "-", and replace/add all lines that are shown as starting with a "+". The red and green are just clarifying guides.)

.
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.

6 Jan 2015, 9:29 AM
#64
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

DrByte:

Just to close the loop here ...
We've opted for ON DUPLICATE KEY UPDATE for ZC v1.6.0:
https://github.com/zencart/zencart/pull/244
and
https://github.com/zencart/zencart/pull/245

I don't wish to be a pain, but is this really the best of the possible solutions?

What happens when two visitors get given the same sessionID, but only one can be entered into the database, wouldn't the "on duplicate key" effectively cause customer#2 to 'steal' the SessionID assigned to customer#1?

On the other hand, the 'insert ignore' will cause customer#2's insert to fail, which I assume will result in a new sessionID being generated for them, and customer#1's sessionID would remain unchanged.

I'm not seeing any benefits with the 'on duplicate key update' in this particular scenario.

Just my 2cents worth.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

6 Jan 2015, 4:27 PM
#65
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,816
Plugin Contributions:
4

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

The place in sessions.php where the "ON DUPLICATE KEY UPDATE" occurs is only called at the END of a script or when PHP needs to write / update the existing session in the database. The same code block also updates the expiry information for the session). Validation and session creation happen earlier in the process.

The change in "sessions.php" basically replaces an existing "select; insert if not in database, update if in database" with a "insert in database, if cannot insert then update instead". By removing the first "select" and using the "on duplicate update", we remove a race condition - typically experienced when people use "multiple windows or tabs" in the browser.

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

6 Jan 2015, 4:54 PM
#66
rixstix avatar

rixstix

Totally Zenned

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

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

I may be misunderstanding something but there are 2 similar threads but offer different solutions.

1 edits sessions.php
1 edits cache.php

The edit to sessions.php did not appear to make any difference in the log files generated.
The edit to cache.php did have an effect. ie: the log files are no longer generated.

Can someone clear my clouded head? Are they intended to resolve different 1062: duplicate entry log files or are they 2 different attempts to resolve the same issue? Or are they both required to resolve the same issue?

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

6 Jan 2015, 5:57 PM
#67
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

Similar issue, two different cases.

.
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.

16 Feb 2015, 11:59 AM
#68
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,743
Plugin Contributions:
56

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

DrByte:

Just to close the loop here ...
We've opted for ON DUPLICATE KEY UPDATE for ZC v1.6.0:
https://github.com/zencart/zencart/pull/244
and
https://github.com/zencart/zencart/pull/245

Do you think this note warrants inclusion in the 1.5.4 fixes thread?
http://www.zen-cart.com/showthread.php?215694-Known-Bugs-%28and-fixes%29-with-v1-5-4

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Feb 2015, 4:32 PM
#69
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.6.0] 1062:Duplicate entry for key 1 in db_cache

swguy:

Do you think this note warrants inclusion in the 1.5.4 fixes thread?
http://www.zen-cart.com/showthread.php?215694-Known-Bugs-%28and-fixes%29-with-v1-5-4
While it's not specific only to 1.5.4, I've posted it there.

.
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.