brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406007571


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -1787,27 +1793,34 @@ public void close(final boolean failed, final boolean 
force) {
          context.reset();
       }
 
+      final ScheduledFuture<?> scheduledFuture = 
server.getScheduledPool().schedule(() -> {
+         callDoClose(failed);
+         logger.warn(ThreadDumpUtil.threadDump("Timed out closing session"));
+      }, timeoutSessionClose, TimeUnit.SECONDS);
+
       context.executeOnCompletion(new IOCallback() {
          @Override
          public void onError(int errorCode, String errorMessage) {
-            callDoClose();
+            scheduledFuture.cancel(true);
+            callDoClose(failed);

Review Comment:
   What are the consequences to execute callDoClose multiple times?



##########
tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/journal/JournalImplTestUnit.java:
##########
@@ -83,6 +90,46 @@ public void testAddUpdateDeleteManyLargeFileSize() throws 
Exception {
 
    }
 
+
+   @Test
+   public void testCommitOnError() throws Exception {
+      ExecutorService executorService = Executors.newSingleThreadExecutor();
+      runAfter(executorService::shutdownNow);
+      setup(10, 10 * 1024 * 1024, true);
+      createJournal();
+      startJournal();
+      load();
+      addTx(1, 1L);
+      ((JournalImpl)journal).markTXError(1, new Exception("test"));
+      OperationContextImpl context = new OperationContextImpl(executorService);
+      try {
+         journal.appendCommitRecord(1, true, context);

Review Comment:
   Can you enforce the check of appendCommitRecord?
   
   ```suggestion
            journal.appendCommitRecord(1, true, context);
            fail("should throw exception")
   ```



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -1787,27 +1793,34 @@ public void close(final boolean failed, final boolean 
force) {
          context.reset();
       }
 
+      final ScheduledFuture<?> scheduledFuture = 
server.getScheduledPool().schedule(() -> {
+         callDoClose(failed);
+         logger.warn(ThreadDumpUtil.threadDump("Timed out closing session"));

Review Comment:
   Can you add more info, i.e. the timeout value, the pending consumers, the 
pending transaction ID?
   ```
   Closing session <this.name> with <conumsers.size()> consumers and 
transaction <tx> after <timeoutSessionClose> milliseconds
   ```
   
   Can we write the log before calling callDoClose?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -1787,27 +1793,34 @@ public void close(final boolean failed, final boolean 
force) {
          context.reset();
       }
 
+      final ScheduledFuture<?> scheduledFuture = 
server.getScheduledPool().schedule(() -> {

Review Comment:
   Can we do this also when force is true?



##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -120,6 +123,9 @@ public class ServerSessionImpl implements ServerSession, 
FailureListener {
 
    private static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+   // TODO: how to configure this?
+   private int timeoutSessionClose = 5;

Review Comment:
   I would add a config item for the sessione close timeout because it changes 
the current behaviour.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
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