Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#56 still have problem with share memory cache

open
nobody
None
9
2003-10-24
2003-10-24
kyle wong
No

envoirnment:

linux kernel 2.4.20-8
apache 1.3.27
php 4.3.4RC1
mmcache 2.4.3

I use mmcache_put() and mmcache_get to cache object
and I get lots of error like this:

child pid 18143 exit signal Segmentation fault (11)
[18140] MMCACHE: PHP crashed on opline 12 of
loadusermap() at /xxxx/xxxxx/UserDB.php:50

[Fri Oct 24 13:59:43 2003] [notice] child pid 18140 exit
signal Segmentation fault (11)
[18152] MMCACHE: PHP crashed on opline 12 of
loadusermap() at /xxxx/xxxxx/gallery/UserDB.php:50

function loadUserMap(){
$userDir = "/www/users";
$this = mmcache_get(userdb2); // line 50
if ($this){
// load $this from mmcache success
// do nothing
}
else if (file_exists("$userDir/userdb.dat")) {
$tmp = getFile("$userDir/userdb.dat");
$this = unserialize($tmp);
mmcache_put(userdb2, $this, 0); // save
$this into mmcache
}
}

Discussion

  • kyle wong
    kyle wong
    2003-10-24

    • priority: 5 --> 9
     
  • kyle wong
    kyle wong
    2003-10-24

    Logged In: YES
    user_id=185056

    follow up:

    I use mmcache_get() and mmcache_put() to speed up my
    page load time from around 15ms to 6-7ms! This somethings
    work, something failed with segmentation fault .... it would be
    very great if I can make it works properly! Thanks.

     
  • kyle wong
    kyle wong
    2003-10-24

    Logged In: YES
    user_id=185056

    sorry ... it should be "This sometime
    work, sometime failed with segmentation fault ...."

     
  • Dmitry Stogov
    Dmitry Stogov
    2003-10-24

    Logged In: YES
    user_id=124551

    I hope, I have fixed this BUG. Fixes will be available with
    MMCache 2.4.4.

     
  • kyle wong
    kyle wong
    2003-10-25

    Logged In: YES
    user_id=185056

    I've installed 2.4.4,
    still have the same crash as 2.4.3

     
  • Dmitry Stogov
    Dmitry Stogov
    2003-10-28

    Logged In: YES
    user_id=124551

    Please, clean the cache and try again with mmcache 2.4.4.
    Can you make a test case for this bug, I will try to catch it.

     
  • kyle wong
    kyle wong
    2003-10-28

    Logged In: YES
    user_id=185056

    I've clicked "clear" and "clean" at mmcache(), stop apache,
    delete everything at /tmp/mmcache/ and start apache again.
    the result is same:
    child pid 12592 exit signal Segmentation fault (11)
    [14221] MMCACHE: PHP crashed on opline 12 of loadusermap
    () at /www/classes/UserDB.php:50

    some of my codes:

    UserDB.php:
    class site_UserDB extends Abstract_UserDB {
    var $userMap;

    function site_UserDB() {
    $userDir = "/www/users/;
    $this->userMap = array();
    }

    function loadUserMap(){
    $userDir = "/www/users/;
    $this = mmcache_get(site_userdb);
    if ($this){
    // do nothing
    }
    else if (file_exists("$userDir/userdb.dat")) {
    $tmp = getFile("$userDir/userdb.dat");
    $this = unserialize($tmp);
    mmcache_put(site_userdb, $this, 0);
    }
    }

    function getUserByUsername($username){
    if (!$this->userMap[kyle]){
    $this->loadUserMap();
    }
    $uid = $this->userMap[$username];
    if (!$uid) {
    $this->rebuildUserMap();
    $uid = $this->userMap[$username];
    if (!$uid) {
    return;
    }
    }

    $user = $this->getUserByUid($uid);
    return $user;
    }

    function getUserByUid($uid) {
    $user = new site_User();
    $user->load($uid);
    return $user;
    }

    function rebuildUserMap() {
    $userDir = "/www/users/;
    foreach ($this->getUidList() as $uid) {
    $tmpUser = $this->getUserByUid($uid);
    $username = $tmpUser->getUsername();
    $this->userMap[$username] = $uid;
    $this->userMap[$uid] = $username;
    }
    mmcache_put(site_userdb, $this, 0);
    return safe_serialize($this, "$userDir/userdb.dat");
    }

    index.php:
    ......
    include("UserDB.php");
    ......
    $site->userDB = new site_UserDB;
    $site->userDB->getUserByUsername($username);
    ......

     
  • kyle wong
    kyle wong
    2003-10-28

    Logged In: YES
    user_id=185056

    follow up:
    my site get around 250,000 pageviews per day ....

    function loadUserMap() will only be called if members logged
    into my site:
    $site->userDB->getUserbyUsername($site->session-
    >username)

    loadUserMap() sometime works, sometime cause seg. fault.
    When seg. fault, my brower will show something like "page not
    found".

     
  • kyle wong
    kyle wong
    2003-10-28

    Logged In: YES
    user_id=185056

    follow up:

    userdb.dat is around 250KB in size....

     
  • kyle wong
    kyle wong
    2003-11-03

    Logged In: YES
    user_id=185056

    tried with cache serialize object, no more seg. fault, but in
    this way, the speed is almost the same as without caching
    the userdb.dat file. page load time is around 12-13 ms (for
    caching unserialized userdb.dat, the time is around 6-7ms,
    but very unstable, many seg. fault)

    PS. I start try to use mmcache_get/mmcache_put for cache
    unserialized object from 2.4.1, this works for 2 days very well
    then suddenly stop my website working with seg. fault.

    function loadUserMap(){
    global $gallery;
    $userDir = "/www/users";

    if ($tmp = mmcache_get(mm_userdb)){
    $this = unserialize($tmp);
    }
    else if (file_exists("$userDir/userdb.dat"))
    {
    // if (file_exists("$userDir/userdb.dat"))
    {
    $tmp =
    getFile("$userDir/userdb.dat");
    $this = unserialize($tmp);
    mmcache_put(mm_userdb, $tmp, 0);
    }
    }

     
  • kyle wong
    kyle wong
    2003-11-03

    Logged In: YES
    user_id=185056

    tried with cache serialize object, no more seg. fault, but in
    this way, the speed is almost the same as without caching
    the userdb.dat file. page load time is around 12-13 ms (for
    caching unserialized userdb.dat, the time is around 6-7ms,
    but very unstable, many seg. fault)

    PS. I start try to use mmcache_get/mmcache_put for cache
    unserialized object from 2.4.1, this works for 2 days very well
    then suddenly stop my website working with seg. fault.

    function loadUserMap(){
    global $gallery;
    $userDir = "/www/users";

    if ($tmp = mmcache_get(mm_userdb)){
    $this = unserialize($tmp);
    }
    else if (file_exists("$userDir/userdb.dat"))
    {
    // if (file_exists("$userDir/userdb.dat"))
    {
    $tmp =
    getFile("$userDir/userdb.dat");
    $this = unserialize($tmp);
    mmcache_put(mm_userdb, $tmp, 0);
    }
    }

     
  • kyle wong
    kyle wong
    2003-11-05

    mmcache_get() cached unserialized object problem testcase

     
    Attachments
  • kyle wong
    kyle wong
    2003-11-05

    Logged In: YES
    user_id=185056

    Dear dstogov,

    here attach a full working testcase, I can reproduce the
    problem with it.