Zen Cart Logo
Forums / Bug Reports / [Done v1.3.6] Caching Error db_cache table

[Done v1.3.6] Caching Error db_cache table

Locked

Views: 3,358

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
22 Dec 2006, 5:55 PM
#1
millisami avatar

millisami

New Zenner

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

[Done v1.3.6] Caching Error db_cache table

Yesterday, I got error as:
1062 Duplicate entry 'zc_7eb4ed1f36d90140477d9474b61e0e26' for key 1
in:
[insert into zen_db_cache set cache_entry_name = 'zc_7eb4ed1f36d90140477d9474b61e0e26', cache_data = 'a:568:{i:0;a:2:{s:6:"cfgkey";s:10:"STORE_NAME";s:8:"cfgvalue";s:13:"Shop In Nepal";}i:1;a:2:{s:6:"cfgkey";s:11:"STORE_OWNER";s:8:"cfgvalue";s:5:"Akhil";}i:2;a:2:{s:6:"cfgkey";s:13:"STORE_COUNTRY";s:8:"cfgvalue";s:3:"149";}i:3;a:2:{s:6:"cfgkey";s:10:"STORE_ZONE";s:8:"cfgvalue";s:1:"1";}i:4;a:2:{s:6:"cfgkey";s:22:"EXPECTED_PRODUCTS_SORT";s:8:"cfgvalue";s:4:"desc";}i:5;a:2:{s:6:"cfgkey";s:23:"EXPECTED_PRODUCTS_FIELD";s:8:"cfgvalue";s:13:"date_expected";}i:6;a:2:{s:6:"cfgkey";s:29:"USE_DEFAULT_LANGUAGE_CURRENCY";s:8:"cfgvalue";s:5:"false";}i:7;a:2:{s:6:"cfgkey";s:25:"LANGUAGE_DEFAULT_SELECTOR";s:8:"cfgvalue";s:7:"Default";}i:8;a:2:{s:6:"cfgkey";s:27:"SEARCH_ENGINE_FRIENDLY_URLS";s:8:"cfgvalue";s:5:"false";}i:9;a:2:{s:6:"cfgkey";s:12:"DISPLAY_CART";s:8:"cfgvalue";s:4:"true";}i:10;a:2:{s:6:"cfgkey";s:32:"ADVANCED_SEARCH_DEFAULT_OPERATOR";s:8:"cfgvalue";s:3:"and";}i:11;a:2:{s:6:"cfgkey";s:18:"STORE_NAME_ADDRESS";s:8:"cfgvalue";s:31:"Shop In, cache_entry_created = '1166808336']

Then I logged into my phpMyAdmin and there in the table zen_db_cache, there was already that key exits. Then I delete that record and my site was back.

But today, I again find this same issue and looked at the zen_db_cache table. The same problem of duplication.
Could anyone help me out what is causing this?

Thanks

23 Dec 2006, 1:19 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.3.6] Caching Error db_cache table

That scenario occurs when there is confusion between the session ID your browser is reporting vs what Zen Cart expects.

I would suggest truncating your zen_db_cache table.
Then clear your browser cookies and cache.

In v1.3.6, as a security precaution, the error handler is written to not display all that detail if the error occurs due to some of the private data it could contain. It's probaby worth upgrading.

1 Mar 2007, 4:15 AM
#3
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: [Done v1.3.6] Caching Error db_cache table

zen-cart 1.3.7

1062 Duplicate entry 'zc_x.......................x' for key 1
in:
[db_cache table]
The problem is not solved. On one of my shops this error occurs frequently.

1 Mar 2007, 4:17 AM
#4
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: [Done v1.3.6] Caching Error db_cache table

DrByte:

That scenario occurs when there is confusion between the session ID your browser is reporting vs what Zen Cart expects.
It not so. Caching at all is not connected to sessions.

3 Mar 2007, 6:49 AM
#5
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: [Done v1.3.6] Caching Error db_cache table

I want to ask the developer team.

Two parallel processes carry out identical quiry to a database.

Process1 get sql_cache_exists(sql)==false
Process2 get sql_cache_exists(sql)==false
Process1 execute(sql)
Process2 execute(sql)
Process1 sql_cache_store(sql,result)
Process2 sql_cache_store(sql,result) and got an error.

There are three variants of the decision:

  1. Find
  function sql_cache_store($zf_query, $zf_result_array) {
    global $db;

Add below

    if($this->sql_cache_exists($zf_query)) return true;
  1. Same as Nomber 1.
    Find
      $sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',
                                                 cache_data = '" . $result_serialize . "',
                   cache_entry_created = '" . time() . "'";

Add above

      $sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "' LIMIT 1";
      $zp_cache_exists = $db->Execute($sql);
      if ($zp_cache_exists->RecordCount() > 0) {
        return true;
      }
  1. Find
      $sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',

Replace by

      $sql = "REPLACE INTO " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',

How you think, what way is better?

12 Apr 2007, 7:32 AM
#6
cjjune avatar

cjjune

Zen Follower

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

Re: [Done v1.3.6] Caching Error db_cache table

Hi a_berezin

Does this proven to eliminate the duplication in DB_Cache_table? I too have the same problem. Running the website in 2 parallel process.

HELP! HELP!:frusty:

12 Apr 2007, 8:14 AM
#7
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.3.6] Caching Error db_cache table

Andrew's method #2 has been implemented in v1.3.8 (Thanks Andrew):

/includes/classes/cache.php
around line 118:case 'database': $result_serialize = $db->prepare_input(serialize($zf_result_array)); $sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "', cache_data = '" . $result_serialize . "', cache_entry_created = '" . time() . "'"; $db->Execute($sql); return true; break;becomes:```
case 'database':
$sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "'";
$zp_cache_exists = $db->Execute($sql);
if ($zp_cache_exists->RecordCount() > 0) {
return true;
}
$result_serialize = $db->prepare_input(serialize($zf_result_array));
$sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',
cache_data = '" . $result_serialize . "',
cache_entry_created = '" . time() . "'";
$db->Execute($sql);
return true;
break;

12 Apr 2007, 12:24 PM
#8
cjjune avatar

cjjune

Zen Follower

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

Re: [Done v1.3.6] Caching Error db_cache table

Great! Thanks alot.:smartalec:

22 Apr 2007, 5:35 PM
#9
cjjune avatar

cjjune

Zen Follower

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

Re: [Done v1.3.6] Caching Error db_cache table

:oops: Hi Dr. Byte

Actually i didnt want to tell you first since this already happened 4 days ago cause i just want to make sure. yeap...the caching error happened again. Yes it happens when i access and has someone else tested it for me at the same time. i sent you an attachment of the db cache table details. i dont know what else has gone wrong.