[ARVADOS] updated: 1.2.0-41-g61bad45c8

Git user git at public.curoverse.com
Tue Sep 11 09:52:43 EDT 2018


Summary of changes:
 lib/controller/federation.go | 13 +++++++++++++
 1 file changed, 13 insertions(+)

       via  61bad45c80df09b92cad96d4541421009183c142 (commit)
      from  a4d77e7f0460e85a4dd8c3730c65fea60a8d212f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 61bad45c80df09b92cad96d4541421009183c142
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Tue Sep 11 09:52:27 2018 -0400

    14087: Rate limit the number of parallel requests
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/lib/controller/federation.go b/lib/controller/federation.go
index 5ea412735..b5ce7c1a4 100644
--- a/lib/controller/federation.go
+++ b/lib/controller/federation.go
@@ -285,16 +285,29 @@ func (h *collectionFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req
 		wg := sync.WaitGroup{}
 		var errors []string
 		var errorCode int = 0
+
+		// use channel as a semaphore to limit it to 4
+		// parallel requests at a time
+		sem := make(chan bool, 4)
+		defer close(sem)
 		for remoteID := range h.handler.Cluster.RemoteClusters {
+			// blocks until it can put a value into the
+			// channel (which has a max queue capacity)
+			sem <- true
+			if sentResponse {
+				break
+			}
 			search := &searchRemoteClusterForPDH{remoteID, &mtx, &sentResponse,
 				&sharedContext, cancelFunc, &errors, &errorCode}
 			wg.Add(1)
 			go func() {
 				h.handler.remoteClusterRequest(search.remoteID, w, req, search.filterRemoteClusterResponse)
 				wg.Done()
+				<-sem
 			}()
 		}
 		wg.Wait()
+
 		if sentResponse {
 			return
 		}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list