Memcache problem

Rok Žlender - July 21, 2008 - 13:47
Project:Advertisement
Version:5.x-1.7
Component:ad module
Category:bug report
Priority:normal
Assigned:Jeremy
Status:needs review
Description

When using memcache caching with ad module approved and offline ads are also served. I have put some ads into offline mode but they are still showing up in rotation. When I disable memcache ads are not displayed any more. Putin ad into offline mode gives me this drupal message:

function(ad_cache_memcache_adcacheapi) action(offline)

I have tried running memcache cron and ad cron and offline ad was still showing up.
This is what debug=2 gives me.

ad_dir: '/home/rzlender/redesign/www/sites/all/modules/ad'
debug: '2'
adcache: 'memcache'
nids: ''
tids: '429645'
hostid: ''
url: ''
quantity: '1'
aid: '0'
ad_display: 'javascript'
Attempting to include cache include file '/home/rzlender/redesign/www/sites/all/modules/ad/cache/memcache/ad_cache_memcache.inc'.
Drupal bootstrap '0'.
Override smtp_library: './sites/all/modules/smtp.inc'
Override cache_inc: './sites/all/modules/memcache/memcache.inc'
Override memcache_servers: 'Array'
Override memcache_bins: 'Array'
Override sf_cache_enabled: ''
Root drupal directory detected as '/home/rzlender/redesign/www'.

/home/rzlender/redesign/www/sites/all/modules/ad/serve.php: // $Id: serve.php,v 1.1.2.2 2007/10/19 02:46:40 jeremy Exp $
/home/rzlender/redesign/www/sites/all/modules/ad/ad.module: // $Id: ad.module,v 1.2.2.29.2.79 2008/06/28 00:15:36 jeremy Exp $

Memcache: entering ad_cache_memcache().
Memcache: retrieving hook info from cache.
Memcache: selecting from the following ad id(s): 919245, 919246.
Selecting 1 ad(s) from 2 total ad(s).
Randomly selecting ad: 1 of 1.
Invoking adserve hook 'adserve_select' in memcache cache.
Memcache: retrieving hook info from cache.
Memcache: adserve_select: no select function defined
Default ID selection in adserve.inc.
Randomly selected ID: 919246.
Displaying AID: 919246.
Memcache: increment action(view) aid(919246) group(429645) hostid(none).
Memcache: incrementing ad-view-919246-429645-none-2008072108 (7)
Invoking adserve hook 'adserve_init_text' in memcache cache.
Function 'ad_cache_memcache_adserve_init_text' does not exist.
Invoking adserve hook 'adserve_exit_text' in memcache cache.
Function 'ad_cache_memcache_adserve_exit_text' does not exist.
document.write('\x3cdiv class=\"image-advertisement\" id=\"ad-919246\"\x3e\x3ca href=\"http://www.redesign.rz.d2.nowpublic.com/ad/redirect/919246/429645/\" title=\"Crowdpower\" target=\"_self\"\x3e\x3cimg src=\"http://media.le.ae.d2.nowpublic.com/promo_crowdpower1.png\" width=\"300\" height=\"250\" alt=\"Crowdpower\" /\x3e\x3c/a\x3e\x3c/div\x3e');

#1

Jeremy - July 21, 2008 - 13:56

This is most likely a bug with the "offline" state which I don't currently use myself and thus is largely untested. If you need a temporary workaround, you may want to try disabling ads by putting them into the "expired" state.

#2

Rok Žlender - July 21, 2008 - 15:25

Yep that did the trick.

#3

Jeremy - July 21, 2008 - 17:08
Assigned to:Anonymous» Jeremy

Thanks for the bug report. I'll review whether this is a general bug with the "offline" state, or only an issue with the ad_cache_memcache module.

#4

Jeremy - August 11, 2008 - 15:03
Status:active» fixed

I'm unable to duplicate this. Using the ad_cache_memcache module, if I put an advertisement into the offline state it stops displaying. If I put it back online, it starts displaying again.

Due to the debug message you mention, I suspect you're using an older, outdated version of the module. You should not see any debug when putting advertisements offline. Please try the latest version of the module, and re-open this issue if you still have a problem.

#5

Anonymous (not verified) - August 25, 2008 - 15:04
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#6

bekkah08 - January 7, 2009 - 04:59

Hi... I'm also having dramas... It returns a message saying

ad_cache_memcache.module: Unable to syncronize cache: Memcache is not installed, memcache_add_server not found.
ad_cache_memcache.module: Unable to build cache: Memcache is not installed, memcache_add_server not found.

and then hangs the site...
What the?

#7

inqui - June 17, 2009 - 17:55
Version:5.x-1.x-dev» 5.x-1.7
Status:closed» active

I can confirm that the issue is still there with both memcache and file cache.
Offline ads are still being displayed when server using any cache.

Output for:
http://mysite/sites/all/modules/ad/serve.php?m=jquery&q=1&t=486642&debug=2

ad_dir: '/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad'
debug: '2'
adcache: 'none'
nids: ''
tids: '486642'
hostid: ''
url: ''
quantity: '1'
aid: '0'
ad_display: 'jquery'
Drupal bootstrap '0'.
Override user_block_seconds_online: '65'
Override sg_notify_enabled: '0'
Override newsletters_signup_webform_id: '647037'
Override media_consultation_webform_id: '647036'
Root drupal directory detected as '/var/www/vhosts/mysite/httpdocs/engine'.

/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad/serve.php: // $Id: serve.php,v 1.1.2.4 2009/01/29 06:26:02 jeremy Exp $
/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad/ad.module: // $Id: ad.module,v 1.2.2.29.2.96 2009/02/11 21:20:52 jeremy Exp $

No cache enabled.
Drupal bootstrap '7'.
Searching for ad from tid list: 486642.
Query: "SELECT a.aid FROM {ads} a INNER JOIN {term_node} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IN(486642);"
Available ads: none
Selecting 1 ad(s) from 0 total ad(s).
adserve_increment action(count) cache(none)
Drupal bootstrap '7'.
Ads displayed: 0
Invoking adserve hook 'adserve_init_text'.
Invoking adserve hook 'adserve_exit_text'.

Output for:
http://mysite/sites/all/modules/ad/serve.php?m=jquery&q=1&c=memcache&t=4...

ad_dir: '/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad'
debug: '2'
adcache: 'memcache'
nids: ''
tids: '486642'
hostid: ''
url: ''
quantity: '1'
aid: '0'
ad_display: 'jquery'
Attempting to include cache include file '/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad/cache/memcache/ad_cache_memcache.inc'.
Drupal bootstrap '0'.
Override user_block_seconds_online: '65'
Override sg_notify_enabled: '0'
Override newsletters_signup_webform_id: '647037'
Override media_consultation_webform_id: '647036'
Root drupal directory detected as '/var/www/vhosts/mysite/httpdocs/engine'.

/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad/serve.php: // $Id: serve.php,v 1.1.2.4 2009/01/29 06:26:02 jeremy Exp $
/var/www/vhosts/mysite/httpdocs/engine/sites/all/modules/ad/ad.module: // $Id: ad.module,v 1.2.2.29.2.96 2009/02/11 21:20:52 jeremy Exp $

Memcache: entering ad_cache_memcache().
Memcache: retrieving hook info from cache.
Memcache: selecting from the following ad id(s): 647092.
Selecting 1 ad(s) from 1 total ad(s).
Randomly selecting ad: 1 of 1.
Invoking adserve hook 'adserve_select' in memcache cache.
Memcache: retrieving hook info from cache.
Memcache: adserve_select: no select function defined
Default ID selection in adserve.inc.
Randomly selected ID: 647092.
Displaying AID: 647092.
Memcache: increment action(view) aid(647092) group(486642) hostid(none).
Memcache: incrementing ad-view-647092-486642-none-2009061710 (6)
Invoking adserve hook 'adserve_init_text' in memcache cache.
Function 'ad_cache_memcache_adserve_init_text' does not exist.
Invoking adserve hook 'adserve_exit_text' in memcache cache.
Memcache: retrieving hook info from cache.
Memcache: adserve_exit_text: no exit_text function defined
ha ha

I noticed that once ad was cached it will never be dropped from cache thus will be always displayed regardless of the ad status changes.
The only thing that fixes this is obviously restarting memcached...

#8

inqui - June 18, 2009 - 19:18

The issue was with ad-taxonomy-cache-tid memcahed keys - these are NEVER updated.

Here is a patch from me that resolves the issue:

ad_cache_memcache.module
find:

$result = db_query("SELECT aid, adtype, redirect, adstatus FROM {ads} WHERE adstatus = 'active' OR adstatus = 'approved' OR adstatus = 'offline'");

replace with:

$result = db_query("SELECT aid, adtype, redirect, adstatus FROM {ads} WHERE adstatus = 'active'");

Cache only active ads, since what was cache is going to display.

after:

    ad_memcache_set("ad-ads", $ads);
    ad_memcache_set("ad-owners", $owners);
    ad_memcache_set("ad-taxonomy", $taxonomy);

add:

    //drop ad-taxonomy-cache-$tid caches for all ad topics
    //otherwise offline and unpublished ads may stay there forever
    $terms_all = db_query('
      SELECT tn.tid
      FROM {term_node} tn
      INNER JOIN {node} n ON (tn.nid = n.nid)
      WHERE n.type = "ad"
    ');
    while ($term = db_fetch_object($terms_all)) {
      ad_memcache_delete("ad-taxonomy-cache-$term->tid");
    }

This makes sure ad-taxonomy-cache-tid keys are flushed as well

#9

inqui - June 18, 2009 - 19:18
Status:active» needs review

#10

xipher84 - October 25, 2009 - 07:22

Hi there, I did have this kind of error and I also did php -i | grep memcache and it says memcache is enabled, but my solution that solved the problem was when I edited the php.ini, i simply modified the extension_dir="./" line to the full path of the extensions directory which now looked like this, extension_dir="/usr/local/lib" -- you need to check where the extension directory of the php reside and make sure memcache.so is there..

then i simply restarted httpd and alas the problem is gone.

you can check the detailed steps here:

http://joemarie-aliling.com/223/php-programming/php-memcache-not-found-p...

 
 

Drupal is a registered trademark of Dries Buytaert.