Item10299: DBCachePlugins::WebDB should retry when reading the cache file fails

pencil
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: DBCachePlugin
Branches:
Reported By: OliverKrueger
Waiting For:
Last Change By: OliverKrueger
Some time ago I made the following patch for DBCachePlugins WebDB.pm cause some DBD archivists had trouble with the cache file.

I forgot about the patch and never used it in a production environment. Maybe somebody else finds it useful.

Index: WebDB.pm
===================================================================
--- WebDB.pm    (Revision 10299)
+++ WebDB.pm    (Arbeitskopie)
@@ -75,8 +75,18 @@
 # WARNING: this breaks on Archivists that are not file-based
 sub _getCacheFile {
   my $this = shift;
+  my $retries = 0;
 
   my $cacheFile = $this->{archivist}->{_file};
+
+  # on some BDB Archivists the above returns undef sometimes
+  my $maxRetries = $Foswiki::cfg{DBCache}{MaxRetries} || 5;
+  while ( (not defined $cacheFile) && ($retries <= $maxRetries) ) {
+    $retries++;
+    sleep(0.5);
+    $cacheFile = $this->{archivist}->{_file};
+  }
+
   writeDebug("cacheFile=$cacheFile");
   return $cacheFile if -f $cacheFile;
 

-- OliverKrueger - 31 Jan 2011

 

ItemTemplate edit

Summary DBCachePlugins::WebDB should retry when reading the cache file fails
ReportedBy OliverKrueger
Codebase
SVN Range
AppliesTo Extension
Component DBCachePlugin
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
Topic revision: r1 - 31 Jan 2011, OliverKrueger
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy