You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by gaohoward <gi...@git.apache.org> on 2017/01/16 11:14:51 UTC

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

GitHub user gaohoward opened a pull request:

    https://github.com/apache/activemq-artemis/pull/960

    ARTEMIS-921 Consumers killed as slow even if overall consuming rate is above threshold

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gaohoward/activemq-artemis master_921

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/960.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #960
    
----
commit 7cefc775baec5e8845cbb56e0bb1111a2bed8b20
Author: Howard Gao <ho...@gmail.com>
Date:   2017-01-16T10:51:54Z

    ARTEMIS-921 Consumers killed as slow even if overall consuming rate is above threshold

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96241694
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3159,6 +3162,9 @@ public void run() {
                             connection.killMessage(server.getNodeID());
                             remotingService.removeConnection(connection.getID());
                             connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress()));
    +                        //break once a consumer gets killed. This can prevent all
    +                        //consumers to this queue get killed all at once.
    +                        break;
    --- End diff --
    
    This fix was using the definition of the JIRA and literally fixing the test, not the overal issue.
    
    The proper fix would be to do some calculation with threshold using consumerSet.size();
    
    I have a small change on QueueIMpl that I think would fix it properly, including both Kill and Notify.
    
    ```java
             Set<Consumer> consumersSet = getConsumers();
    
             if (consumersSet.size() == 0 || queueRate  < (threshold * consumersSet.size())) {
                if (logger.isDebugEnabled()) {
                   logger.debug("Insufficient messages received on queue \"" + getName() + "\" to satisfy slow-consumer-threshold. Skipping inspection of consumer.");
                }
    
                return;
             }
    
             for (Consumer consumer : consumersSet) {
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96241875
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3159,6 +3162,9 @@ public void run() {
                             connection.killMessage(server.getNodeID());
                             remotingService.removeConnection(connection.getID());
                             connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress()));
    +                        //break once a consumer gets killed. This can prevent all
    +                        //consumers to this queue get killed all at once.
    +                        break;
    --- End diff --
    
    you will also need to change your test as you made an assumption a consumer would be killed. Since the overal rate doesn't satisfy the condition of the threshold no consumers should be killed..
    
    
    @gaohoward I will let you handle these changes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by gaohoward <gi...@git.apache.org>.
Github user gaohoward commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96331558
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3159,6 +3162,9 @@ public void run() {
                             connection.killMessage(server.getNodeID());
                             remotingService.removeConnection(connection.getID());
                             connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress()));
    +                        //break once a consumer gets killed. This can prevent all
    +                        //consumers to this queue get killed all at once.
    +                        break;
    --- End diff --
    
    @clebertsuconic Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96232634
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3128,6 +3128,9 @@ private SlowConsumerReaperRunnable(long checkPeriod, float threshold, SlowConsum
     
           @Override
           public void run() {
    +         if (getConsumerCount() == 0) {
    --- End diff --
    
    Can you remove this? this is a useless statement here.
    you will be counting the number of elements on consumerSet once, for than later perform a for (Consumer consumer : getConsumerSet()) that will perform the very same operation. It is duplicating effort for no improvement IMO.
    
    
    If you are having a race condition shown by a test, then it's a different issue that we must investigate, this would only hide the real issue if that was the case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/960


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96239419
  
    --- Diff: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleSlowConsumerTest.java ---
    @@ -0,0 +1,261 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements. See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License. You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.activemq.artemis.tests.integration.client;
    +
    +import org.apache.activemq.artemis.api.core.ActiveMQException;
    +import org.apache.activemq.artemis.api.core.SimpleString;
    +import org.apache.activemq.artemis.api.core.client.ClientConsumer;
    +import org.apache.activemq.artemis.api.core.client.ClientMessage;
    +import org.apache.activemq.artemis.api.core.client.ClientProducer;
    +import org.apache.activemq.artemis.api.core.client.ClientSession;
    +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
    +import org.apache.activemq.artemis.api.core.client.ServerLocator;
    +import org.apache.activemq.artemis.core.server.ActiveMQServer;
    +import org.apache.activemq.artemis.core.server.RoutingType;
    +import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
    +import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
    +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
    +import org.apache.activemq.artemis.utils.ConcurrentHashSet;
    +import org.apache.activemq.artemis.utils.TimeUtils;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import java.util.Set;
    +
    +public class MultipleSlowConsumerTest extends ActiveMQTestBase {
    +
    +   private int checkPeriod = 3;
    +   private int threshold = 1;
    +
    +   private ActiveMQServer server;
    +
    +   private final SimpleString QUEUE = new SimpleString("SlowConsumerTestQueue");
    +
    +   private ServerLocator locator;
    +
    +   @Before
    +   @Override
    +   public void setUp() throws Exception {
    +      super.setUp();
    +
    +      server = createServer(true, true);
    +
    +      AddressSettings addressSettings = new AddressSettings();
    +      addressSettings.setSlowConsumerCheckPeriod(checkPeriod);
    +      addressSettings.setSlowConsumerThreshold(threshold);
    +      addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.KILL);
    +
    +      server.start();
    +
    +      server.getAddressSettingsRepository().addMatch(QUEUE.toString(), addressSettings);
    +
    +      server.createQueue(QUEUE, RoutingType.ANYCAST, QUEUE, null, true, false);
    +
    +      locator = createFactory(true);
    +   }
    +
    +   /**
    +    * This test creates 3 consumers on one queue. A producer sends
    +    * messages at a rate of 2 mesages per second. Each consumer
    +    * consumes messages at rate of 1 message per second. The slow
    +    * consumer threshold is 1 message per second.
    +    * Based on the above settings, at least one of the consumers
    +    * will be removed during the test, but at least one of the
    +    * consumers will remain and all messages will be received.
    +    */
    +   @Test
    +   public void testMultipleConsumersOneQueue() throws Exception {
    --- End diff --
    
    Please move this test to SlowConsumerTest...
    
    That test run in Page and non paging mode.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96264629
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3159,6 +3162,9 @@ public void run() {
                             connection.killMessage(server.getNodeID());
                             remotingService.removeConnection(connection.getID());
                             connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress()));
    +                        //break once a consumer gets killed. This can prevent all
    +                        //consumers to this queue get killed all at once.
    +                        break;
    --- End diff --
    
    @gaohoward Actually, I'm doing it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96234261
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3159,6 +3162,9 @@ public void run() {
                             connection.killMessage(server.getNodeID());
                             remotingService.removeConnection(connection.getID());
                             connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress()));
    +                        //break once a consumer gets killed. This can prevent all
    +                        //consumers to this queue get killed all at once.
    +                        break;
    --- End diff --
    
     this fix is not valid....
    We need all the slow consumers to be killed. 
    We need to calculate the rate properly then. threshold / number of consuemrs for instance.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #960: ARTEMIS-921 Consumers killed as slow eve...

Posted by gaohoward <gi...@git.apache.org>.
Github user gaohoward commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/960#discussion_r96233863
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---
    @@ -3128,6 +3128,9 @@ private SlowConsumerReaperRunnable(long checkPeriod, float threshold, SlowConsum
     
           @Override
           public void run() {
    +         if (getConsumerCount() == 0) {
    --- End diff --
    
    Yes this is not relevant to this issue. I'll remove it. Thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---