[Catalyst] Race conditions in C::P::PageCache
Toby Corkindale
toby at ymogen.net
Mon Jun 26 19:51:10 CEST 2006
Hi,
looking through Catalyst::Plugin::PageCache, there appear to be some
race conditions, here's one example: (line ~253 of PageCache.pm):
# Keep an index cache of all pages that have been cached, for use
# with clear_cached_page
my $index = $c->cache->get( "_page_cache_index" ) || {};
$index->{$key} = 1;
# Save date in cache
$c->cache->set( "_page_cache_index", $index,
$c->config->{page_cache}->{no_expire} );
Here, the index is retrieved, updated, and stored, non-atomically.
So, it would be quite possible for another process to have pulled the
index out, adjusted a different key, before the first process had saved
the key.. The first process then saves the entire index, and then the
second process saves its own index, and overwrites the changes made by
the first.
If using Cache::FastMmap, you can use the get_and_set() function to do
atomic changes - I'm not sure about the other cache:: modules though.
Toby
More information about the Catalyst
mailing list