cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-10136) Fix thread growth/leak issue
Date Fri, 10 Nov 2017 16:35:01 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-10136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16247745#comment-16247745
] 

ASF GitHub Bot commented on CLOUDSTACK-10136:
---------------------------------------------

rhtyd closed pull request #2314: CLOUDSTACK-10136: Fix RemoteHostEndPoint thread growth
URL: https://github.com/apache/cloudstack/pull/2314
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
index 3bad62eb574..b438bc121e4 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
@@ -18,17 +18,15 @@
  */
 package org.apache.cloudstack.storage;
 
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -54,9 +52,11 @@
 
 public class RemoteHostEndPoint implements EndPoint {
     private static final Logger s_logger = Logger.getLogger(RemoteHostEndPoint.class);
+
     private long hostId;
     private String hostAddress;
     private String publicAddress;
+
     @Inject
     AgentManager agentMgr;
     @Inject
@@ -65,10 +65,10 @@
     protected SecondaryStorageVmDao vmDao;
     @Inject
     protected HostDao _hostDao;
-    private ScheduledExecutorService executor;
+
+    private static ExecutorService executorService = Executors.newCachedThreadPool(new NamedThreadFactory("RemoteHostEndPoint"));
 
     public RemoteHostEndPoint() {
-        executor = Executors.newScheduledThreadPool(10, new NamedThreadFactory("RemoteHostEndPoint"));
     }
 
     private void configure(Host host) {
@@ -134,17 +134,17 @@ public Answer sendMessage(Command cmd) {
     }
 
     private class CmdRunner extends ManagedContextRunnable implements Listener {
-        final AsyncCompletionCallback<Answer> callback;
-        Answer answer;
+        private final AsyncCompletionCallback<Answer> callback;
+        private Answer answer;
 
-        public CmdRunner(AsyncCompletionCallback<Answer> callback) {
+        CmdRunner(final AsyncCompletionCallback<Answer> callback) {
             this.callback = callback;
         }
 
         @Override
         public boolean processAnswers(long agentId, long seq, Answer[] answers) {
-            answer = answers[0];
-            executor.schedule(this, 10, TimeUnit.SECONDS);
+            this.answer = answers[0];
+            RemoteHostEndPoint.executorService.submit(this);
             return true;
         }
 
@@ -204,7 +204,7 @@ public boolean processTimeout(long agentId, long seq) {
 
         @Override
         protected void runInContext() {
-            callback.complete(answer);
+            this.callback.complete(this.answer);
         }
     }
 
diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index e414b6c4c35..c25c1adaf7a 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -106,16 +106,19 @@ protected EndPoint findEndPointInScope(Scope scope, String sqlBase,
Long poolId)
         StringBuilder sbuilder = new StringBuilder();
         sbuilder.append(sqlBase);
 
-        if (scope.getScopeType() == ScopeType.HOST) {
-            sbuilder.append(" and h.id = ");
-            sbuilder.append(scope.getScopeId());
-        } else if (scope.getScopeType() == ScopeType.CLUSTER) {
-            sbuilder.append(" and h.cluster_id = ");
-            sbuilder.append(scope.getScopeId());
-        } else if (scope.getScopeType() == ScopeType.ZONE) {
-            sbuilder.append(" and h.data_center_id = ");
-            sbuilder.append(scope.getScopeId());
+        if (scope != null) {
+            if (scope.getScopeType() == ScopeType.HOST) {
+                sbuilder.append(" and h.id = ");
+                sbuilder.append(scope.getScopeId());
+            } else if (scope.getScopeType() == ScopeType.CLUSTER) {
+                sbuilder.append(" and h.cluster_id = ");
+                sbuilder.append(scope.getScopeId());
+            } else if (scope.getScopeType() == ScopeType.ZONE) {
+                sbuilder.append(" and h.data_center_id = ");
+                sbuilder.append(scope.getScopeId());
+            }
         }
+
         // TODO: order by rand() is slow if there are lot of hosts
         sbuilder.append(") t where t.value<>'true' or t.value is null");    //Added
for exclude cluster's subquery
         sbuilder.append(" ORDER by rand() limit 1");


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Fix thread growth/leak issue
> ----------------------------
>
>                 Key: CLOUDSTACK-10136
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10136
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>    Affects Versions: 4.5.2, 4.6.2, 4.7.1, 4.10.0.0, 4.9.2.0, 4.8.1.1, 4.9.3.0
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: 4.11.0.0
>
>
> For long running mgmt server with large amounts of templates etc, large amounts of waiting
threads are seen that start with the 'RemoteHostEndPoint-' prefix. These async threads are
responsible mostly for checking template/volume upload/download progress/states. They kick
everytime a template is being checked/downloaded setup etc.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message