Item10257: Caching broken in Solaris 10
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: PageCache
Branches:
I just tried out the
PageCaching feature for the first time, and found it was broken on my Solaris 10 server:
| 2011-01-14T08:39:21Z warning | can't lock cache db: Bad file number at /data/www/wiki/lib/Foswiki/Cache/DB_File.pm line 167.
at /usr/local/lib/perl5/5.8.8/CGI/Carp.pm line 356
CGI::Carp::realdie('can\'t lock cache db: Bad file number at /data/www/wiki/lib/F...') called at /usr/local/lib/perl5/5.8.8/CGI/Carp.pm line 437
CGI::Carp::die('can\'t lock cache db: Bad file number') called at /data/www/wiki/lib/Foswiki/Cache/DB_File.pm line 167
Foswiki::Cache::DB_File::_tie('Foswiki::Cache::DB_File=HASH(0xaf59b8)', 'ro') called at /data/www/wiki/lib/Foswiki/Cache/DB_File.pm line 40
Foswiki::Cache::DB_File::init('Foswiki::Cache::DB_File=HASH(0xaf59b8)', 'Foswiki=HASH(0x9a8b18)') called at /data/www/wiki/lib/Foswiki/Cache.pm line 31
Foswiki::Cache::new('Foswiki::Cache::DB_File', 'Foswiki=HASH(0x9a8b18)') called at /data/www/wiki/lib/Foswiki/Cache/DB_File.pm line 29
Foswiki::Cache::DB_File::new('Foswiki::Cache::DB_File', 'Foswiki=HASH(0x9a8b18)') called at /data/www/wiki/lib/Foswiki/PageCache.pm line 62
Foswiki::PageCache::new('Foswiki::PageCache', 'Foswiki=HASH(0x9a8b18)') called at /data/www/wiki/lib/Foswiki.pm line 1665
Foswiki::new('Foswiki', 'undef', 'Foswiki::Request=HASH(0x98fd3c)', 'HASH(0x97f178)') called at /data/www/wiki/lib/Foswiki/UI.pm line 309
Foswiki::UI::__ANON__() called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 415
eval {...} called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 407
Error::subs::try('CODE(0x98f994)', 'HASH(0x9a88c0)') called at /data/www/wiki/lib/Foswiki/UI.pm line 435
Foswiki::UI::_execute('Foswiki::Request=HASH(0x98fd3c)', 'CODE(0x98fa0c)', 'view', 1) called at /data/www/wiki/lib/Foswiki/UI.pm line 277
Foswiki::UI::handleRequest('Foswiki::Request=HASH(0x98fd3c)') called at /data/www/wiki/lib/Foswiki/Engine/CGI.pm line 37
Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x6846b8)') called at /data/www/wiki/bin/view line 24
ModPerl::ROOT::ModPerl::Registry::data_www_wiki_bin_view::handler('Apache2::RequestRec=SCALAR(0x418c4c)') called at /usr/local/lib/perl5/site_perl/5.8.8/sun4-solaris/ModPerl/RegistryCooker.pm line 204
eval {...} called at /usr/local/lib/perl5/site_perl/5.8.8/sun4-solaris/ModPerl/RegistryCooker.pm line 204
ModPerl::RegistryCooker::run('ModPerl::Registry=HASH(0x4748a8)') called at /usr/local/lib/perl5/site_perl/5.8.8/sun4-solaris/ModPerl/RegistryCooker.pm line 170
ModPerl::RegistryCooker::default_handler('ModPerl::Registry=HASH(0x4748a8)') called at /usr/local/lib/perl5/site_perl/5.8.8/sun4-solaris/ModPerl/Registry.pm line 31
ModPerl::Registry::handler('ModPerl::Registry', 'Apache2::RequestRec=SCALAR(0x418c4c)') called at /data/www/wiki/lib/Foswiki/PageCache.pm line 0
eval {...} called at /data/www/wiki/lib/Foswiki/PageCache.pm line 0.
|
Looking into this further, it appears to be due to Foswiki::Cache::DB_File::_tie opening the lock file for writing and then requesting a shared lock. The error raised fits with the documented behaviour:
EBADF
The fildes argument is not a valid open file descriptor; or the cmd argument is F_SETLK, F_SETLK64, F_SETLKW, or F_SETLKW64, the type of lock, l_type, is a shared lock (F_RDLCK), and fildes is not a valid file descriptor open for reading; or the type of lock l_type is an exclusive lock (F_WRLCK) and fildes is not a valid file descriptor open for writing.
I was able to fix this in my local codebase with the following, but not sure if this has ramifications to any intended functionality (everything appears to be working for me..):
--- DB_File.pm.orig 2010-11-10 11:29:12.000000000 +1100
+++ DB_File.pm 2011-01-14 19:27:36.409280000 +1100
@@ -154,15 +154,17 @@
# aquire a file lock
my $lockfile = "$this->{filename}.lock";
- open( $this->{lock}, ">$lockfile" )
- or die "can't create lockfile $lockfile";
if ( $mode eq 'rw' ) {
+ open( $this->{lock}, ">$lockfile" )
+ or die "can't create lockfile $lockfile";
$mode = O_CREAT | O_RDWR;
flock( $this->{lock}, LOCK_EX )
or die "can't lock cache db: $!";
}
elsif ( $mode eq 'ro' ) {
+ open( $this->{lock}, "<$lockfile" )
+ or die "can't create lockfile $lockfile";
$mode = O_CREAT | O_RDONLY;
flock( $this->{lock}, LOCK_SH )
or die "can't lock cache db: $!";
--
MatthewFlint - 14 Jan 2011
The foswiki Page Cache has been completely rewritten for Foswiki 1.2. We don't have Solaris available for testing. We need someone to test this once 1.2 is in alpha / beta after the beginning of the year. The code referenced in your suggested patch no longer exists. Would you be willing to help with 1.2 testing? ... Thanks
--
GeorgeClark - 23 Dec 2014
I have moved on from my previous role and no longer have access to any Solaris servers. Hope you were able to find someone to test.
--
MatthewFlint - 02 May 2015