Zen Cart Logo
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

Views: 10,423

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,818
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).

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.

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

drbyte

Sensei

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

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

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

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

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
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.

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?

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

drbyte

Sensei

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

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

Similar issue, two different cases.

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

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,692
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