From 8a568b09f9af275127ef0b9e459e5ddb31c638e8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 11 Nov 2021 11:21:11 -0500 Subject: [PATCH] LP#1949910: serialize deleting items from item bucket This patch serializes the fetching and fleshing of items to delete when the delete-from-item-bucket action is invoked, thereby avoiding possible drone starvation from open-ils.search. It also throws up the progress dialog for good measure while the deletion occurs. To test ------- [1] Set up an item bucket with 25-50 items. [2] From the item bucket intervace, invoke the action to delete all of the items. [3] Note that the open-ils.search.asset.copy.fleshed2.retrieve calls, one for each item, are all made simultaneously. Assuming stock max_children settings, this will cause open-ils.search to log that some requests are hitting the backlog. [4] Apply the patch and refresh the item bucket page, then repeat step 2 (it doesn't matter for this purpose that the items have already been deleted). This time, the open-ils.search API calls are made serially and a progress bar is displayed while the deletion takes place. Verify that no requests hit the backlog. Signed-off-by: Galen Charlton Signed-off-by: Jeff Davis Signed-off-by: Jane Sandberg --- .../web/js/ui/default/staff/cat/bucket/copy/app.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js index 81372a1f68..5ef5c286a6 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js @@ -516,9 +516,9 @@ function($scope, $routeParams, bucketSvc , egGridDataProvider, egCore) { .controller('ViewCtrl', ['$scope','$q','$routeParams','$timeout','$window','$uibModal','bucketSvc','egCore','egOrg','egUser', - 'ngToast','egConfirmDialog', + 'ngToast','egConfirmDialog','egProgressDialog', function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc , egCore , egOrg , egUser , - ngToast , egConfirmDialog) { + ngToast , egConfirmDialog , egProgressDialog) { $scope.setTab('view'); $scope.bucketId = $routeParams.id; @@ -759,11 +759,13 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc egCore.strings.CONFIRM_DELETE_COPY_BUCKET_ITEMS_FROM_CATALOG, '', {} ).result.then(function() { + egProgressDialog.open(); var fleshed_copies = []; - var promises = []; + + var chain = $q.when(); angular.forEach(copies, function(i) { - promises.push( - egCore.net.request( + chain = chain.then(function() { + return egCore.net.request( 'open-ils.search', 'open-ils.search.asset.copy.fleshed2.retrieve', i.id @@ -771,10 +773,11 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc copy.ischanged(1); copy.isdeleted(1); fleshed_copies.push(copy); - }) - ); + }); + }); }); - $q.all(promises).then(function() { + + chain.finally(function() { egCore.net.request( 'open-ils.cat', 'open-ils.cat.asset.copy.fleshed.batch.update', @@ -800,6 +803,7 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc } bucketSvc.bucketNeedsRefresh = true; drawBucket(); + egProgressDialog.close(); }); }); }); -- 2.11.0