From: dbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 26 Apr 2011 14:13:22 +0000 (+0000)
Subject: Make authority_control_fields.pl resistant to database timeouts
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c10bc69714b2410e9f96d9cefa550b85f7999cda;p=evergreen%2Fjoelewis.git

Make authority_control_fields.pl resistant to database timeouts

LP 771237 describes how on an underpowered system, the work that
authority_control_fields.pl tries to do on a per-record basis may hit the
CStore default timeout of 6 seconds for a transaction and automatically
end the transaction, resulting in no work being committed once the script tries
to update the bibliographic record. Searching each controlled field for a
matching authority record can be costly in a database with millions of
authority records.

To enable the script to accomplish its work on underpowered test systems, use a
regular read-only CStoreEditor session to accomplish the lookups and create a
separate CStoreEditor session to issue the update in a transaction if required.

Signed-off-by: Dan Scott <dscott@laurentian.ca>


git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20312 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/src/support-scripts/authority_control_fields.pl b/Open-ILS/src/support-scripts/authority_control_fields.pl
index 1b28a6eb2d..a7b6b752dc 100755
--- a/Open-ILS/src/support-scripts/authority_control_fields.pl
+++ b/Open-ILS/src/support-scripts/authority_control_fields.pl
@@ -339,7 +339,7 @@ my %controllees = (
 foreach my $rec_id (@records) {
     # print "$rec_id\n";
 
-    my $e = OpenILS::Utils::CStoreEditor->new(xact=>1);
+    my $e = OpenILS::Utils::CStoreEditor->new();
     # State variable; was the record changed?
     my $changed;
 
@@ -418,6 +418,7 @@ foreach my $rec_id (@records) {
         }
     }
     if ($changed) {
+        my $editor = OpenILS::Utils::CStoreEditor->new(xact=>1);
         # print $marc->as_formatted();
         my $xml = $marc->as_xml_record();
         $xml =~ s/\n//sgo;
@@ -427,9 +428,9 @@ foreach my $rec_id (@records) {
         $xml = OpenILS::Application::AppUtils->entityize($xml);
 
         $record->marc($xml);
-        $e->update_biblio_record_entry($record);
+        $editor->update_biblio_record_entry($record);
+        $editor->commit();
     }
-    $e->commit();
 }
 
 __END__