Zen Cart Logo
Forums / General Questions / 1062 Duplicate entry for key 1 in table seo_cache

1062 Duplicate entry for key 1 in table seo_cache

Views: 1,015

Results 1 to 2 of 2
7 Jul 2013, 4:33 PM
#1
dmagic avatar

dmagic

Totally Zenned

Join Date:
Oct 2008
Posts:
594
Plugin Contributions:
0

1062 Duplicate entry for key 1 in table seo_cache

Please help

1062 Duplicate entry 'ca34fbe5f9a075091ad59abf02c259a7-1' for key 'PRIMARY'
in:
[INSERT INTO seo_cache (cache_id, cache_language_id, cache_name, cache_data, cache_global, cache_gzip, cache_method, cache_date, cache_expires) VALUES ('ca34fbe5f9a075091ad59abf02c259a7', '1', 'seo_urls_v2_products', 'rX1Lj+NKcvXev+LbjQ2YQFGvkuCVYXvpBwx7bVASS8UuSdSIUtet/vXfiXOSFCkpI1l9Z4DprlvNyGdkZMSJR27Lt+pY/v1f/uu///Nf//df/uf//uOf//3f/i//yz/+v78cqs25

This happend when click on product or category .
When refresh it's gone .

8 Jul 2013, 3:54 AM
#2
lhungil avatar

lhungil

Totally Zenned

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

Re: 1062 Duplicate entry for key 1 in table seo_cache

MySQL MyISAM tables (I'm guessing "seo_cache" is a MyISAM table) do not typically provide full ACID compliance. In particular they typically lack support for atomic read / write or transactions...

Basically one thread is trying to update an entry which already exists. This can happen if your webserver is running PHP multithreaded and two separate threads check if the entry exists at the same time... Both see it does not exist in the database... And both try to write the new entry. The slower the servers (and higher the website load), the higher the chance this can happen.

On "refresh" the error disappears because the entry is already in "seo_cache". The code reads the entry from the cache, finds the entry is not stale (old - based upon a timestamp), and uses the cache entry. Then if it needs to update the entry it uses a SQL "update" not an "insert".

Some thoughts:

  • You can check if the alternative URL generation module you are using is the latest version (some optimizations might be present in newer versions to reduce the risk).
  • If you have Query Cache installed, make sure your alternative URL generation module knows about Query Cache and disables Query Cache from trying to cache requests to "seo_cache".
  • You can also try doing a "repair" on the table "seo_cache". While uncommon, sometimes the database tables can become corrupt (and thus perform poorly - or act up).
  • You could configure (or ask your server admin) to use a single threaded PHP... But this may have a negative performance impact.
  • Disable the alternative URL generation module from using a SQL cache. This will cause the "seo_table" to not be used.