From 3b3fb95ed7947d967c7ccdd5335d7659792bb18c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 3 Jan 2017 11:59:26 -0500 Subject: [PATCH] LP#1653742 Copy tree authoritative API share cstores Avoid opening one cstore connection per requested org unit in the open-ils.cat.asset.copy_tree.retrieve.authoritative API by creating a single shared cstore connection at the top of the API shared by all API actions. To test: 1. In one terminal: % tail osrfsys.log | grep transaction.begin 2. In another terminal: srfsh% request open-ils.cat open-ils.cat.asset.copy_tree.retrieve.authoritative "AUTOTOKEN", 217, [1,2,3,4,5,6,7,8,9] 3. 9 cstore transactions are opened before patching. After patching, only 1 is created. Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm index 5267ddd6e2..87409e27d6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm @@ -640,14 +640,19 @@ sub retrieve_copies { @org_ids = ($user_obj->home_ou); } + # Create an editor that can be shared across all iterations of + # _build_volume_list(). Otherwise, .authoritative calls can result + # in creating too many cstore connections. + my $e = new_editor(); + if( $self->api_name =~ /global/ ) { - return _build_volume_list( { record => $docid, deleted => 'f', label => { '<>' => '##URI##' } } ); + return _build_volume_list($e, { record => $docid, deleted => 'f', label => { '<>' => '##URI##' } } ); } else { my @all_vols; for my $orgid (@org_ids) { - my $vols = _build_volume_list( + my $vols = _build_volume_list($e, { record => $docid, owning_lib => $orgid, deleted => 'f', label => { '<>' => '##URI##' } } ); push( @all_vols, @$vols ); } @@ -660,10 +665,12 @@ sub retrieve_copies { sub _build_volume_list { + my $e = shift; my $search_hash = shift; + $e ||= new_editor(); + $search_hash->{deleted} = 'f'; - my $e = new_editor(); my $vols = $e->search_asset_call_number([ $search_hash, -- 2.11.0