By andre75 on
I keep getting those and I am wondering why. Seems like it is trying to insert stuff into the cache that is already there. I was wondering if there is anything I can do to avoid this.
Duplicate entry 'http://www.mysite.com/subfolder/index.html' for key 1 query: INSERT INTO cache
Comments
Yes?
Noone else has these problems?
What are you doing when this happens?
gpdinoz
"If you're not getting the answers you want maybe you're asking the wrong questions"
Regards
Geoff
Just browsing
I am browsing around on my new site.
I am calling the page it is trying to insert into cache.
This is how the error looks like:
Duplicate entry 'http://www.mysite/subdir/index.html' for key 1 query: INSERT INTO cache (cid, data, created, expire, headers) VALUES ('http://www.mysite/subdir/index.html',
... a bunch of ascii chars
/mypath/includes/database.mysql.inc on line 66.
So how do I ask the right questions?
Oh wait that was prob. a "wrong" question too.
No that was a good question
No that was a good question however anything after a username at the bottom of a post is a signature and is added to all posts so it is not a specific directive to you.
Did you try searching the forum. I tried "cache problems" and found some posts with the same problem.
gpdinoz
"If you're not getting the answers you want maybe you're asking the wrong questions"
Regards
Geoff
Me too - cache database problems
Me too - I keep getting the same problems in my production sites. I see it in the error log. That's why I've neutralized the drupal cache in most of my sites, until a proper solution is found.
Hints:
* The problem happens on both MySQL 4 and MySQL 3..i
* I am ususally seeting the problem only in the error log, not myself, but it is quite frequent (avg 10-20 times each day).
* No user is authorized to modify the site except me, so the problem happens for anonymous read-only surfers. Does anyone has any idea why such a user would trigger a cache modification?
I am currently using drupal 4.6.1 with a few patches applied.
I've looked at Drupal's changelog, as This post suggests, but I haven't seen an occurance of the word 'cache' since version 4.4.
Please advise
Thanks in advance,
Amnon
-
Personal: Bring Dolphin's Simple Joy to your Work - Job - Career
Professional: Small Business Web Hosting Strategies, עסקים ברשת - מדריך ליזם
Disable cache
I have disabled the cache but I am still getting the error and the cache is still growing. This is weird. Why is the cache being built up even after it is disabled?
-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com
Ah yes
Seems like I am not the only one, LOL:
http://www.google.com/search?hl=en&lr=&q=%22Duplicate+entry%22+%22INSERT...
Here is the short link:
http://tinyurl.com/d3xv6
How about this
I dug around in common.inc and found error levels. I then put this line into my settings.php:
Supposedly this does not stop the error from being logged but it should not show up on the screen of the visitor.
Update:
Nevermind. The way I read the file now it's not going to help.
Do what db_next_id does
In database.mysql.inc, db_next_id they use the REPLACE INTO syntax, which says try an insert, and replace any existing values with the same primary key. This would mean we would need to move the cache_set to the data base sepecific files.
The other approach for MySQL is the INSERT...ON DUPLICATE KEY syntax:
@db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s') ON DUPLICATE KEY UPDATE `data`='%s', `created`=%d, `expire`=%d, `headers`='%s'", $cid, $data, time(), $expire, $headers, $data, time(), $expire, $headers);I'm currently trying the second one, with good success.
what file?
Simbot,
Can you be more specific as to which database file to edit? I'm very new to Drupal and I can't seem to find a file called database.mysql.inc. I did find one called civicspace.mysql and updates.inc - are these the files that need editing?
In your includes directory
DRUPAL_DIR/includes/bootstrap.inc is the file you need to modify. There is a function in there called cache_set. Replace it with the following. When I was talking about database.mysql.inc, I was pointing out that this solution will only work for mysql, so we should really move the method to database.mysql.inc, and put a similar method in database.pgsql.inc. For my purposes this hack is fine.
function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
$data = db_encode_blob($data);
@db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s') ON DUPLICATE KEY UPDATE `data`='%s', `created`=%d, `expire`=%d, `headers`='%s'", $cid, $data, time(), $expire, $headers, $data, time(), $expire, $headers);
}
Thanks
Thanks for the post. I have not seen the problem since I have 3 database users now sharing the load (my host lets me have 3 per database). So everytime someone visits my site, one of those 3 will be randomly used to connect to the DB. Amazingly since then I never saw the problem again.
But I will try it, to be on the safe side!
Thanks
Does this fix work with
Does this fix work with 4.6.6?
Since I disabled caching I get keep Not Found type errors in the log, and they all originate from the same IP. It's the same paths as were filling up the log before but were then logged as INSERT values for the cache table.
Edit: Editing my .htaccess file I managed to block the offender temporarily at least.
--
Jakob Persson - blog
Leancept – Digital effect and innovation agency
could be a bug in a module
this may be because one of the modules you have hasn't implemented its menu hook correctly.
i recommend disabling modules one at a time (beginning with ones not available to all users), and seeing if the problem disappears. when it does, you've found the culprit module.
if my guess is right, one of your enabled module has a "menu hook" method that returns a menu as cacheable even though it's not available to all users all the time (which the module handbook says not to do).
i say this because when developing my module's "menu hook" method, at first i had it return its menu as cacheable, and then when i tried to access pages as an unregistered user (who can't view the module), i got the same error you get.
but when i returned my menu as uncacheable (and disabled and reenabled the module), the problem went away.
that's why i'm guessing another module is making the same mistake.
good luck.
-vann
ps it's not necessary for a module to have a menu for this to be a problem; modules can register invisible menus for internal purposes (like mine).
I get this same error all
I get this same error all over.
I got the same error
I use drupal 4.6.5. and php 5 This is what happened during somebody searched:
Full log entry for search:
It also occurs in various taxonomy entries
Vann Right?
Hi,
I'm getting the same problem:
Duplicate entry 'menu:1:en' for key 1 query: INSERT INTO cache (cid,...I don't have cache enabled, nor do I have custom modules w/new or buggy menu items in this install. However, these errors are only generated when I goto admin>>menu, making me think that vann is right. Incidentally, I've got many drupal installs, and the problem site is the only one using image galleries. More research forthcoming.
The same here with drupal 4.5.5
My Drupal installation is not published and just me and another user are using it. With admin acount I get this error in diferent screens.
I have those modules:
block
book
comment
contact
filter
help
locale
menu
node
page
path
profile
simplenews
story
system
taxonomy
tinymce
upload
user
watchdog
webform
Any clue?
Marco Solanas