Bugzilla – Attachment 25172 Details for
Bug 11078
rebuild_zebra.pl can lose updates due to race condition during full rebuilds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11078: Follow-up for flock eval
Bug-11078-Follow-up-for-flock-eval.patch (text/plain), 2.50 KB, created by
Marcel de Rooy
on 2014-02-10 14:08:20 UTC
(
hide
)
Description:
Bug 11078: Follow-up for flock eval
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-02-10 14:08:20 UTC
Size:
2.50 KB
patch
obsolete
>From 75e6292d2dc1848c6b79d24891bfe02b47e7e5a0 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 10 Feb 2014 14:55:05 +0100 >Subject: [PATCH] Bug 11078: Follow-up for flock eval >Content-Type: text/plain; charset=utf-8 > >This patch adds a subroutine where the flock is once tested in an eval. >Just to be sure that flock has been implemented and prevent a fatal error. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > misc/migration_tools/rebuild_zebra.pl | 29 +++++++++++++++++++++++++---- > 1 files changed, 25 insertions(+), 4 deletions(-) > >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index 28b858c..2f29301 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -43,6 +43,7 @@ my $where; > my $offset; > my $run_as_root; > my $run_user = (getpwuid($<))[0]; >+my $use_flock; > > my $verbose_logging = 0; > my $zebraidx_log_opt = " -v none,fatal,warn "; >@@ -185,17 +186,17 @@ open my $LockFH, q{>}, $lockfile or die "$lockfile: $!"; > if ($daemon_mode) { > while (1) { > # For incremental updates, skip the update if the updates are locked >- if (flock($LockFH, LOCK_EX|LOCK_NB)) { >+ if (_flock($LockFH, LOCK_EX|LOCK_NB)) { > do_one_pass() if ( zebraqueue_not_empty() ); >- flock($LockFH, LOCK_UN); >+ _flock($LockFH, LOCK_UN); > } > sleep $daemon_sleep; > } > } else { > # all one-off invocations, wait for the lock to free >- flock($LockFH, LOCK_EX); >+ _flock($LockFH, LOCK_EX); > do_one_pass(); >- flock($LockFH, LOCK_UN); >+ _flock($LockFH, LOCK_UN); > } > > >@@ -749,6 +750,26 @@ sub do_indexing { > > } > >+sub _flock { >+# test if flock is present; if so, use it; if not, return true >+# op refers to the official flock operations incl LOCK_EX, LOCK_UN, etc. >+# combining LOCK_EX with LOCK_NB returns immediately >+ my ($fh, $op)= @_; >+ if( !defined($use_flock) ) { >+ #check if flock is present; if not, you will have a fatal error >+ my $i=eval('flock($fh, $op)'); >+ #assuming that $fh and $op are fine(..), an undef i means no flock >+ $use_flock= defined($i)? 1: 0; >+ print "Warning: flock could not be used!\n" if $verbose_logging && !$use_flock; >+ return 1 if !$use_flock; >+ return $i; >+ } >+ else { >+ return 1 if !$use_flock; >+ return flock($fh, $op); >+ } >+} >+ > sub print_usage { > print <<_USAGE_; > $0: reindex MARC bibs and/or authorities in Zebra. >-- >1.7.7.6
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11078
:
22044
|
22045
|
22205
|
22458
|
22506
|
22508
|
22532
|
22985
|
22992
|
23220
|
23221
|
23573
|
23574
|
25114
|
25172
|
25330
|
25412
|
25446
|
25447