[drupal-devel] [bug] cache_set sometimes fails

Jeremy drupal-devel at drupal.org
Sat Mar 26 13:54:22 UTC 2005


Issue status update for http://drupal.org/node/19442

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  wiz
 Updated by:   Jeremy at kerneltrap.org
 Status:       active

Ah, I see.  Hmm, that shouldn't be a fatal error.  What if you try going
to "administer >> settings" and in the "Error handling" section set
"Error reporting" to "Write errors to the log"?


Jeremy at kerneltrap.org



Previous comments:
------------------------------------------------------------------------

March 25, 2005 - 12:12 : wiz

When cache_set is called for a cache entry which already exists in that
very form (including the timestamp), the first UPDATE will change no
rows (db_affected_rows() == 0), and the subsequent INSERT will fail
because the row (i.e., the primary key) already exists.
This can happen only if calling cache_set with the same parameters
twice in one second -- but this can happen.  Example:
locale_refresh_cache() may be called often from locale() when no rows
exist in the translation_* tables (which is a bug by itself).  The
error message then is:
user error: Duplicate entry 'locale:de' for key 1
query: INSERT INTO cache (cid, data, created, expire, headers) VALUES
('locale:de', 'N;', 1111769323, 0, '') in
/var/www/drupal-cvs/includes/database.mysql.inc on line 66.
I can think of no obvious general fix, except to add another column to
cache that is updated with a random number, or to use a SELECT to check
for the existence of the row.  The function locale_refresh_cache in
locale.module seems to have a bug too (separate post).


------------------------------------------------------------------------

March 25, 2005 - 13:05 : Jeremy at kerneltrap.org

Why is this a problem?  If the cache entry is identical, why do you want
two copies of it?  It seems to me the error is expected and can be
ignored.
In any case, you can add microseconds to a timestamp if you really need
a finer granularity.  I used this method with locking.


------------------------------------------------------------------------

March 25, 2005 - 16:49 : wiz

Well, instead of a well-formed page the user just sees a blank page with
this error message - not an acceptable result, is it? Of course I don't
want two identical cache entries...





More information about the drupal-devel mailing list