Cache::Cache Stale Segments

J

Jeff Nokes

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top