Cache::Cache Stale Segments

Discussion in 'Perl' started by Jeff Nokes, Sep 30, 2003.

  1. Jeff Nokes

    Jeff Nokes Guest

    Hello,
    I'm using Cache::SharedMemoryCache with an Apache 1.3.28 / mod_perl
    1.28 / Mason instance on RedHat Linux 7.2. The caching mechanism
    seems to work fine, it creates one shared memory segment and one
    semophore when in use. What I noticed was that when I gracefully shut
    apache down (completely), the segment and semaphore remain. I believe
    this is mostly intentional from design, but I would like to be able to
    remove any shared memory explicitly set by the application upon the
    apache parent process shutdown, via an END{} block in my startup.pl.
    Kind of like how Apache automatically removes its own shared memory
    segment

    ipcs:
    key shmid owner perms bytes nattch
    status
    0x00000000 2326529 apache 600 46084 1 dest


    I've tried using the built in methods from Cache::Cache (Clear(),
    Purge(), remove()) to destroy the shared memory, but all it does is
    wipe out the keys and their respective data, it doesn't get rid of the
    actual segment/semaphore allocation in the OS. So, I've just been
    resorting to using ipcrm manually after I shut apache down.

    Since my keys stay the same for my shared data, Apache utilizes the
    already allocated segment/semaphore upon restart, so there is no leak
    issue. But the ops personnel who maintain the application don't like
    having stale shared memory allocations hanging around once the
    process(es) that is using them (apache) is shut down. Besides, by
    design, the cache is cleared on startup and reloaded then anyway,
    there's no business reason to keep the data there when there are no
    processes accessing it.

    Anyone have any suggestions on how I can take care of this
    automatically during Apache's shutdown process? Or at least, how I
    can get access to the shared mem id that Linux provides when the
    memory is allocated? That way I could at least 'system()' out ipcrm
    calls upon a graceful shutdown. Short of modifying the code in
    Cache::Cache myself to meet my own needs, I'm not sure how to do any
    of this.

    Thanks in advance,
    - Jeff
    Jeff Nokes, Sep 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Rivers

    Stale Forms

    John Rivers, Sep 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    542
    Tim_Mac
    Sep 7, 2005
  2. Replies:
    0
    Views:
    380
  3. Timo Nentwig

    stale objects in collections

    Timo Nentwig, Aug 21, 2006, in forum: Java
    Replies:
    9
    Views:
    494
    Patricia Shanahan
    Aug 22, 2006
  4. Replies:
    0
    Views:
    312
  5. tgiles

    Python and stale file handles

    tgiles, Apr 17, 2008, in forum: Python
    Replies:
    2
    Views:
    316
Loading...

Share This Page