Download & Extend

Duplicate entry in ctools_css_cache

Project:Chaos tool suite (ctools)
Version:7.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

Hi,

im am observing a sporadic error in the ctools css cache table (see below). The error message occurs only for exactly one element. I understand that this is probably caused by a script being executed twice, and no locking in place. Or is this the result of a misconfiguration on the panels-UI?

FILE: modules/ctools/includes/css.inc on line 79.

ERROR: Duplicate entry 'rounded-corner:.rounded-corner' for key 'PRIMARY'

QUERY: INSERT INTO tableprefix_ctools_css_cache (cid, filename, css, filter) VALUES ('rounded-corner:.rounded-corner', ...

Comments

#1

I think you're probably right about the lack of locking causing this. Not quite sure how to fix this. We're not supposed to use lock tables, but...

#2

I have similar error message:

Duplicate entry 'rounded-corner:.rounded-corner' for key 1 query: INSERT INTO ctools_css_cache (cid, filename, css, filter) VALUES (&#
...
/sites/all/modules/ctools/includes/css.inc, line 79.

Have you managed to fix this somehow?

#3

Hey bloto,

I am not aware of fixing it or applying a patch, besides the usual updates, but the problem disappeared.

The only thing I see from my svn logs that I have altered and might be related, was a small perfomance thingie in panels. Please report in case it solves your problems.

(only applicable if you are using panels and have css aggregation enabled)

Index: panels/plugins/styles/corners/rounded_corners.inc
===================================================================
--- panels/plugins/styles/corners/rounded_corners.inc  (revision 848)
+++ panels/plugins/styles/corners/rounded_corners.inc  (revision 944)
@@ -132,7 +132,7 @@
     $filename = ctools_css_store($css_id, _panels_rounded_corners_css($idstr), FALSE);
   }

-  drupal_add_css($filename, 'module', 'all', FALSE);
+  drupal_add_css($filename, 'module', 'all', TRUE);
}

#4

Thank you,
I applied it yesterday, so far 1 event occured with this. So there must be something else that fix this.... I will keep observing..

#5

Status:active» postponed (maintainer needs more info)

The css cache system has been improved quite a bit since this bug was posted. Is anyone still getting this? I've never seen this happen in my testing.

#6

just got one:

Duplicate entry 'flexible:30' for key 'PRIMARY' query: ctools_css_store /* Anonymous : ctools_css_store */ INSERT INTO ctools_css_cache (cid, filename, css, filter) VALUES ('flexible:30', 'sites/xxxx.net/files/ctools/css/54c5fef89fa2a2908f95171c692ddafc.css', '.panels-flexible-column-30-main {\n float: left;\n width: 99.0000%;\n}\n\n.panel-flexible-30-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-30-center {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-30-main-row-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-column-30-3 {\n position: relative;\n float: left;\n background-color: transparent;\n width: 160px;\n}\n\n.panels-flexible-column-30-4 {\n float: left;\n width: 300px;\n}\n\n.panels-flexible-column-30-2 {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-30-1-left {\n margin-left: -160px;\n}\n\n* html .panels-flexible-row-30-1-left {\n left: 160px;\n}\n\n.panels-flexible-row-30-1-inside {\n padding-left: 160px;\n padding-right: 300px;\n}\n\n.panels-flexible-row-30-1-right {\n margin-right: -300px;\n}\n\n.panels-flexible-region-30-left {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-30-5-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-30-main_ {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-30-6-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-30-right {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-30-7-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n', 0) in /home/xxxx/public_html/drupal/sites/all/modules/ctools/includes/css.inc on line 79.

#7

Version:6.x-1.x-dev» 6.x-1.6
Priority:minor» normal

Hi

I don't know whether this is related or not but I got a similar warning message as:
User warning: Duplicate entry 'flexible:21' for key 1 query: INSERT INTO ctools_css_cache (cid, filename, css, filter) VALUES ('flexible:21', 'sites/default/files/ctools/css/b3805cc44f071d62d08fdbd3f92a991b_0.css', '.panels-flexible-column-21-main {\n float: left;\n width: 99.0000%;\n}\n\n.panel-flexible-21-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-21-center {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-21-main-row-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-column-21-2 {\n float: left;\n width: 32.6999%;\n}\n\n.panels-flexible-column-21-3 {\n float: left;\n width: 33.6161%;\n}\n\n.panels-flexible-column-21-4 {\n float: left;\n width: 32.6840%;\n}\n\n.panels-flexible-row-21-1-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-21-column1 {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-21-5-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-21-column2 {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-21-6-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-21-column3 {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-21-7-inside {\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.panels-flexible-region-21-right {\n float: left;\n width: 253px;\n}\n\n.panels-flexible-region-21-bottom {\n float: left;\n width: 99.0000%;\n}\n\n.panels-flexible-row-21-8-inside {\n padding-left: 0px;\n padding-right: 253px;\n}\n\n.panels-flexible-row-21-8-right {\n margin-right: -253px;\n}\n\n', 0) in _db_query() (line 141 of /mnt/www/html/nasa/docroot/includes/database.mysqli.inc).

This happened when a user login and go to his/her account page.

Any glue on this.

Thanks
Truyenle

#8

Status:postponed (maintainer needs more info)» active

I got a similar message, like "Duplicate entry in ...".
Backtrace shows that error happens in ctools_css_store() function:

<?php
 
// Remove any previous records.
 
db_query("DELETE FROM {ctools_css_cache} WHERE cid = '%s'", $id);
 
// on high-loaded sites two or more users can reach this point at the same time
 
$filename = ctools_css_cache($css, $filter);
 
// and we have "duplicate entry..."
 
db_query("INSERT INTO {ctools_css_cache} (cid, filename, css, filter) VALUES ('%s', '%s', '%s', %d)", $id, $filename, $css, $filter);
?>

i think, we need to use some kind of lock (maybe lock_*() functions), or use INSERT IGNORE

#9

I am getting these errors regularly now.

user warning: Duplicate entry 'rounded-corner:.rounded-corner' for key 1 query: INSERT INTO ctools_css_cache (cid, filename, css, filter) ..............................

user warning: Duplicate entry 'flexiblev2:10' for key 1 query: INSERT INTO ctools_css_cache (cid, filename, css, filter) ..........................................

Has somebody found a solution? Thanks.

#10

Hi, I am getting similiar errors but I am running on the latest Drupal 7 version along with the following modules; Domain Access, Rules, Views, Display Suites, Date, Calendar, References, Organic Groups, CTOOLs, and Aquia Marena theme.

I get this error when i try to create new content of any type!!!

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'flexiblev2:8' for key 1: INSERT INTO {ctools_css_cache} (cid, filename, css, filter) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => flexiblev2:8 [:db_insert_placeholder_1] => public://ctools/css/bab59090150caf0c64e27afa1b36eef1.css [:db_insert_placeholder_2] => .panels-flexible-region { padding: 0; } .panels-flexible-region-inside { padding-right: 0.5em; padding-left: 0.5em; } .panels-flexible-region-inside-first { padding-left: 0; } .panels-flexible-region-inside-last { padding-right: 0; } .panels-flexible-column { padding: 0; } .panels-flexible-column-inside { padding-right: 0.5em; padding-left: 0.5em; } .panels-flexible-column-inside-first { padding-left: 0; } .panels-flexible-column-inside-last { padding-right: 0; } .panels-flexible-row { padding: 0 0 0.5em 0; margin: 0; } .panels-flexible-row-last { padding-bottom: 0; } .panels-flexible-column-8-main { float: left; width: 99.0000%; } .panels-flexible-8-inside { padding-right: 0px; } .panels-flexible-8 { width: auto; } .panels-flexible-region-8-center { float: left; width: 99.0000%; } .panels-flexible-row-8-main-row-inside { padding-right: 0px; } [:db_insert_placeholder_3] => 0 ) in ctools_css_store() (line 87 of /home/idev7615/public_html/sites/all/modules/ctools/includes/css.inc).

#11

Version:6.x-1.6» 7.x-1.0

Just updating the version.

#12

I just got the following:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7d174ecc369e7e8a3f1c5057b38ac65b' for key 'PRIMARY': INSERT INTO {ctools_css_cache} (cid, filename, css, filter) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 7d174ecc369e7e8a3f1c5057b38ac65b [:db_insert_placeholder_1] => public://ctools/css/7d174ecc369e7e8a3f1c5057b38ac65b_0.css [:db_insert_placeholder_2] => /* css3pie */ .br5-2, .form-item-apachesolr-panels-search-form, .bluegrad, .greengrad, .redgrad, .greengrad-sub-btn, .bluegrad-check-btn, .garbage-green, .darkblue, .darkgreen, .br10, .br5, .br3, .br2, .br5-4, .cityott-spotlight, .cityott-region .panel-pane, .cityott-region .br5, #base-srchbx, .cluster-title, .service-btn, #wb-head #wb-head-in #base-bnr #base-bnr-in #base-srchbx .search-form #base-srch, #wb-head #wb-head-in #base-bnr #base-bnr-in #base-srchbx #base-srch-submit, #wb-head #wb-head-in #base-fullhd #base-fullhd-in ul li a, input.ctools-jump-menu-button, input#edit-submit-facilities, a.bbb-cursor, a.bbb, a.bbb-request, .region-cityott-two-front-slideshow ul.tabs li a, .region-cityott-two-bryant-slideshow ul.tabs li a, .page-recherche-search ul.facetapi-facetapi-tab-links .tabs li, .page-recherche-search ul.facetapi-facetapi-tab-links .tabs li a, .page-recherche-search ul.facetapi-facetapi-tab-links, .pane-service-ottawa-navigation-structure-panel-pane-2 .view-footer, .pane-service-ottawa-navigation-structure-panel-pane-2 .view-footer a { behavior: url(/sites/all/libraries/PIE/PIE.htc); } [:db_insert_placeholder_3] => 0 ) in ctools_css_store() (line 87 of /DRUPAL7/sites/all/modules/contrib/ctools/includes/css.inc).

This is possibly related to:
#1135848: Feedback on using export ui for the first time
#1721884: Integrity constraint error after updating to 7.x-1.1

#13

Similar Error 7.12:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'flexiblev2:4' for key 'PRIMARY': INSERT INTO {ctools_css_cache} (cid, filename, css, filter) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => flexiblev2:4 [:db_insert_placeholder_1] => public://ctools/css/7b89ad9bf1044fb5fc9f628169553363_2.css [:db_insert_placeholder_2] => .panels-flexible-region { padding: 0; } .panels-flexible-region-inside { padding-right: 1em; padding-left: 1em; } .panels-flexible-region-inside-first { padding-left: 0; } .panels-flexible-region-inside-last { padding-right: 0; } .panels-flexible-column { padding: 0; } .panels-flexible-column-inside { padding-right: 1em; padding-left: 1em; } .panels-flexible-column-inside-first { padding-left: 0; } .panels-flexible-column-inside-last { padding-right: 0; } .panels-flexible-row { padding: 0 0 0.5em 0; margin: 0; } .panels-flexible-row-last { padding-bottom: 0; } .panels-flexible-column-4-main { float: left; width: 99.0000%; } .panels-flexible-4-inside { padding-right: 0px; } .panels-flexible-4 { width: auto; } .panels-flexible-region-4-center { float: left; width: 99.0000%; } .panels-flexible-row-4-main-row-inside { padding-right: 0px; } [:db_insert_placeholder_3] => 0 ) in ctools_css_store() (line 87 of /home/jicny/public_html/drupal/sites/all/modules/ctools/includes/css.inc).

#14

Version:7.x-1.0» 7.x-1.2

Same problem here and I wonder why we shouldn't use lock tables (as @merlinofchaos suggested in comment #1).

#15

We (my company) also have the same problem (using drupal 7.17 and ctools 1.2).

"MESSAGE PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'flexiblev2:g4_layout' for key 'PRIMARY': INSERT INTO {ctools_css_cache}..."

So a delete action is being performed prior to this insert but a second insert is performed before the first insert has a chance to finish.
To avoid locking the table, since the delete is actually being performed we considered using a try - catch in ctools_css_store() where to execute the db_insert and if record is already present simply return it. This fixes the problem but we're not very happy with altering the contrib module.
Maybe this could be implemented within ctools...

Thoughts anyone?

#16

Version:7.x-1.2» 7.x-1.3
Status:active» needs review

For us, with 4 front servers running this problems happens a lot. WSOD. The main problem it that delete+insert is not in a transaction. But this can be solved very easily by using db_merge instead of db_insert (as all the server are trying to insert the same record. Updating it is not a problem).

So here's the patch

AttachmentSizeStatusTest resultOperations
ctools-duplicate-entry-ctools-ccs-cache-539534-16.patch480 bytesIdleFAILED: [[SimpleTest]]: [MySQL] 113 pass(es), 0 fail(s), and 2 exception(s).View details | Re-test

#17

Was too simple :-(
I made a typo on a 2 lines patch :-)

Here is the correct version.

AttachmentSizeStatusTest resultOperations
ctools-duplicate-entry-ctools-ccs-cache-539534-17.patch479 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 121 pass(es).View details | Re-test

#18

Status:needs review» reviewed & tested by the community

#17 is RTBC.

nobody click here