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

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

                Author: ASF GitHub Bot
            Created on: 08/Oct/25 07:26
            Start Date: 08/Oct/25 07:26
    Worklog Time Spent: 10m 
      Work Description: brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2412564130


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ThreadDumpUtil.java:
##########
@@ -35,6 +35,10 @@
 public final class ThreadDumpUtil {
    private static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+   public static String threadDump() {
+      return threadDump("");
+   }
+

Review Comment:
   Is this change still required?



##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java:
##########
@@ -496,6 +496,46 @@ public void testCompactPrepareRestart() throws Exception {
       loadAndCheck();
    }
 
+   @Test
+   public void testCommitOnRolledBack() throws Exception {
+
+      ExecutorService executorService = Executors.newSingleThreadExecutor();
+      runAfter(executorService::shutdownNow);
+
+      setup(2, 60 * 1024, false);
+
+      createJournal();
+
+      startJournal();
+
+      load();
+
+      addTx(1, 2);
+      rollback(1);
+      startCompact();
+
+      OperationContextImpl context = new OperationContextImpl(executorService);
+      journal.appendCommitRecord(1, false, context);
+      CountDownLatch latch = new CountDownLatch(1);
+      context.executeOnCompletion(new IOCallback() {
+         @Override
+         public void done() {
+            latch.countDown();

Review Comment:
   Should the commit always fail?
   ```suggestion
   ```



##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalAnalyzerImpl.java:
##########
@@ -49,28 +52,53 @@ public CriticalAnalyzerImpl() {
        *  otherwise in case of a deadlock, or a starvation of the server the 
analyzer won't pick up any
        *  issues and won't be able to shutdown the server or halt the VM
        */
-      this.scheduledComponent = new ActiveMQScheduledComponent(null, null, 
checkTimeNanoSeconds, TimeUnit.NANOSECONDS, false) {
+      this.scheduledComponent = new CriticalAnalyzerScheduledComponent(this, 
null, null, checkTimeNanoSeconds, checkTimeNanoSeconds, TimeUnit.NANOSECONDS, 
false);
 
-         @Override
-         public void run() {
-            logger.trace("Checking critical analyzer");
-            check();
-         }
+   }
 
-         @Override
-         protected ActiveMQThreadFactory getThreadFactory() {
-            return new ActiveMQThreadFactory("critical-analyzer", true, 
getThisClassLoader());
-         }
+   private static class CriticalAnalyzerScheduledComponent extends 
ActiveMQScheduledComponent {
 
-         private ClassLoader getThisClassLoader() {
-            return 
AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> 
CriticalAnalyzerImpl.this.getClass().getClassLoader());
+      private final CriticalAnalyzerImpl criticalAnalyzer;
 
-         }
+      public CriticalAnalyzerScheduledComponent(CriticalAnalyzerImpl 
criticalAnalyzer,
+                                                ScheduledExecutorService 
scheduledExecutorService,
+                                                Executor executor,
+                                                long initialDelay,
+                                                long checkPeriod,
+                                                TimeUnit timeUnit,
+                                                boolean onDemand) {
+         super(scheduledExecutorService, executor, initialDelay, checkPeriod, 
timeUnit, onDemand);
+         this.criticalAnalyzer = criticalAnalyzer;
+      }
+
+
+      @Override
+      public void run() {
+         logger.trace("Checking critical analyzer");
+         criticalAnalyzer.check();
+      }
+
+      @Override
+      protected ActiveMQThreadFactory getThreadFactory() {
+         return new ActiveMQThreadFactory("critical-analyzer", true, 
getThisClassLoader());
+      }
+
+      private ClassLoader getThisClassLoader() {
+         return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) 
() -> criticalAnalyzer.getClass().getClassLoader());
+      }
+
+      /** Schedule an action to kick in the critical analyzer.
+       *  If this future is not cancelled in time, the critical analyzer will 
kick in. */
+      public ScheduledFuture<?> kickIt(CriticalComponent component) {
+         return scheduledExecutorService.schedule(() -> {
+            criticalAnalyzer.fireActions(component);
+         }, period, timeUnit);
+      }

Review Comment:
   What about a SimpleCriticalComponentImpl to add and remove in place of 
scheduling a new task for each session close?
   
   I developed a POC to explain what I mean, see 
https://github.com/brusdev/activemq-artemis/commit/d73d4438acacd9d5b87a8a71d6d636164a6978bc





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

    Worklog Id:     (was: 986233)
    Time Spent: 1h 10m  (was: 1h)

> Lingering sessions after a storage timeout
> ------------------------------------------
>
>                 Key: ARTEMIS-5694
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5694
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.42.0
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.43.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> We had reports of sessions not closing for an unkown situation, probably on 
> storage.
> I am adding a timeout verification and adding extra logs in case this happens.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to