[ 
https://issues.apache.org/jira/browse/ARTEMIS-4476?focusedWorklogId=893033&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-893033
 ]

ASF GitHub Bot logged work on ARTEMIS-4476:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Nov/23 00:54
            Start Date: 30/Nov/23 00:54
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on code in PR #4694:
URL: https://github.com/apache/activemq-artemis/pull/4694#discussion_r1410032896


##########
tests/integration-tests-isolated/src/test/java/org/apache/activemq/artemis/tests/integration/isolated/client/ConnectionDroppedTest.java:
##########
@@ -498,4 +500,64 @@ public void beforeCreateSession(String name,
 
    }
 
+
+   @Test
+   public void testForceDropOpenWire() throws Throwable {
+      ActiveMQServer server = createServer(true, createDefaultConfig(true));
+      server.start();
+
+      AtomicInteger errors = new AtomicInteger(0);
+
+      Queue serverQueue = server.createQueue(new 
QueueConfiguration("test-queue").setRoutingType(RoutingType.ANYCAST).setAddress("test-queue").setAutoCreated(false));
+
+      CountDownLatch beforeCreateCalled = new CountDownLatch(1);
+      CountDownLatch goCreateConsumer = new CountDownLatch(1);
+      server.registerBrokerPlugin(new ActiveMQServerConsumerPlugin() {
+         @Override
+         public void afterCreateConsumer(ServerConsumer consumer) throws 
ActiveMQException {
+            if (consumer.getQueue() == serverQueue) {
+               logger.info("Creating a consumer at {}", consumer.getQueue());
+               beforeCreateCalled.countDown();
+               try {
+                  goCreateConsumer.await(5, TimeUnit.MINUTES);
+               } catch (Exception e) {
+                  logger.warn(e.getMessage(), e);
+               }
+            }
+         }
+      });
+
+      ExecutorService executorService = Executors.newFixedThreadPool(1);
+      runAfter(executorService::shutdownNow);
+
+      ConnectionFactory factory = CFUtil.createConnectionFactory("OPENWIRE", 
"tcp://localhost:61616");
+
+      CountDownLatch done = new CountDownLatch(1);
+
+      executorService.execute(() -> {
+         try (Connection connection = factory.createConnection();
+              Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+              MessageConsumer consumer = 
session.createConsumer(session.createQueue("test-queue"))) {
+         } catch (Exception e) {
+            logger.warn(e.getMessage(), e);
+         } finally {
+            done.countDown();
+         }
+      });
+
+      Assert.assertTrue(beforeCreateCalled.await(5, TimeUnit.MINUTES));
+
+      server.getRemotingService().getConnections().forEach(r -> {
+         r.fail(new ActiveMQException("this is a simulation"));

Review Comment:
   this would block with the current version as this is calling shutdown. 
   
   I'm blocking the thread on purpose there.
   
   
   I could not reproduce the leakage here. But I believe the change I made 
would be better in this case.
   
   
   I'm open to suggestions.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 893033)
    Time Spent: 5h  (was: 4h 50m)

> Connection Failure Race Conditions in AMQP and Core
> ---------------------------------------------------
>
>                 Key: ARTEMIS-4476
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4476
>             Project: ActiveMQ Artemis
>          Issue Type: Task
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>          Time Spent: 5h
>  Remaining Estimate: 0h
>
> Failure Detection has a possibility to a race condition with the processing 
> of the client packets (or frames in the case of AMQP).
> This is because Netty detects the failure and removes the connection objects 
> while the packets are still processing things. 
> I was not able to reproduce this particular issue, but I have seen a case 
> from a memory dump where the consumer was created while the connection was 
> already dropped, leaving the consumer isolated without any communication with 
> clients.
> That particular case I could see a possibility because of these races.
> I am adding tests to exercise connection failure in stress and I was able to 
> reproduce other issues.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to