You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "clebertsuconic (via GitHub)" <gi...@apache.org> on 2025/10/03 16:17:03 UTC
[PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
clebertsuconic opened a new pull request, #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952
(no comment)
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2402535269
##########
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:
@brusdev I haven't decided yet on where to have such configuration.. or if we could use another value in its place.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#issuecomment-3372755611
@brusdev can you review this?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406580527
##########
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 was thinking of adding it to the configuration.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406549915
##########
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:
what default?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2409995299
##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/SessionCloseTimeoutTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.persistence;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer;
+import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * A simple test-case used for documentation purposes.
+ */
+public class SessionCloseTimeoutTest extends ActiveMQTestBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ ActiveMQServer server;
+
+ @BeforeEach
+ protected void createServer() throws Exception {
+
+ ConfigurationImpl configuration = createBasicConfig(0).setJMXManagementEnabled(false).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, generateInVMParams(0), "invm"));
+
+ configuration.setCloseTimeout(500);
+
+ HashMap<String, Object> extraConfig = new HashMap<>();
+ HashMap<String, Object> regularConfig = new HashMap<>();
+ regularConfig.put("sessionCloseTimeout", 1000);
+
+ configuration.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, regularConfig, "netty", extraConfig));
Review Comment:
Is the `sessionCloseTimeout` config still used?
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java:
##########
@@ -1538,4 +1538,9 @@ default String resolvePropertiesSources(String propertiesFileUrl) {
default boolean isUsingDatabasePersistence() {
return getStoreConfiguration() != null && getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE;
}
+
+ /** Timeout applied when closing sessions or connections. */
+ Configuration setCloseTimeout(int timeout);
+
+ int getCloseTimeout();
Review Comment:
`CloseTimeout` seems very generic, what about `ClientCloseTimeout` or something more specific as `SessionCloseTimeout` and `ConnectionCloseTimeout`?
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java:
##########
@@ -1538,4 +1538,9 @@ default String resolvePropertiesSources(String propertiesFileUrl) {
default boolean isUsingDatabasePersistence() {
return getStoreConfiguration() != null && getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE;
}
+
+ /** Timeout applied when closing sessions or connections. */
+ Configuration setCloseTimeout(int timeout);
Review Comment:
Users can only set this value programmatically or by using a broker property. Is that on purpose?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2402539804
##########
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:
Perhaps we need a logger... if you're okay with having this output (@brusdev )
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2405913619
##########
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2405916499
##########
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?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2402536817
##########
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:
System property perhaps?
That's TBD..
The test I wrote simulate the condition artificially
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2402533785
##########
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:
if we decide to be optional, we could only do this if configured
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406548800
##########
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:
@brusdev where? configuration / System.property?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#issuecomment-3376958485
I am converting this to a draft as I found a few scenarios where the lineupContext could be called without calling the actual storage.. (after exceptions)
Also I will make this to use CriticalAnalyzer
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2408207833
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -1777,37 +1787,56 @@ public void close(final boolean failed) {
@Override
public void close(final boolean failed, final boolean force) {
synchronized (this) {
- if (closed) {
+ if (closing) {
return;
}
- closed = true;
+ closing = true;
}
if (force) {
context.reset();
}
+ final ScheduledFuture<?> scheduledFuture;
+ if (server.getConfiguration().getCloseTimeout() > 0) {
+ scheduledFuture = server.getScheduledPool().schedule(() -> {
+ long txID = tx != null ? tx.getID() : -1L;
+
+ ActiveMQServerLogger.LOGGER.sessionCloseTimeout(name, server.getConfiguration().getCloseTimeout(), consumers.size(), txID, remotingConnection, ThreadDumpUtil.threadDump());
+
+ callDoClose(failed);
Review Comment:
I thought it wouldn't be needed as the context is going away anyways...
But I guess It doesn't hurt.. I made the change.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2407056353
##########
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:
Sounds good to me +1
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2413877836
##########
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:
I liked the idea... although I used the simple extension points we already have. just had the Session to implement CriticalComponent
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2410681647
##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/SessionCloseTimeoutTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.persistence;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer;
+import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * A simple test-case used for documentation purposes.
+ */
+public class SessionCloseTimeoutTest extends ActiveMQTestBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ ActiveMQServer server;
+
+ @BeforeEach
+ protected void createServer() throws Exception {
+
+ ConfigurationImpl configuration = createBasicConfig(0).setJMXManagementEnabled(false).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, generateInVMParams(0), "invm"));
+
+ configuration.setCloseTimeout(500);
+
+ HashMap<String, Object> extraConfig = new HashMap<>();
+ HashMap<String, Object> regularConfig = new HashMap<>();
+ regularConfig.put("sessionCloseTimeout", 1000);
+
+ configuration.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, regularConfig, "netty", extraConfig));
Review Comment:
oops.. thanks
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406023724
##########
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 we 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?
##########
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 we enforce the check of appendCommitRecord?
```suggestion
journal.appendCommitRecord(1, true, context);
fail("should throw exception")
```
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406032277
##########
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:
It should be optional and we could do this also when force is true?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406609969
##########
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:
it shouldn't really mater, but I am adding an extra property that will control actually closed versus closing
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406630433
##########
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:
I'm thinking we should always do this.... force will probably not be needed any more
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2408029887
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java:
##########
@@ -1777,37 +1787,56 @@ public void close(final boolean failed) {
@Override
public void close(final boolean failed, final boolean force) {
synchronized (this) {
- if (closed) {
+ if (closing) {
return;
}
- closed = true;
+ closing = true;
}
if (force) {
context.reset();
}
+ final ScheduledFuture<?> scheduledFuture;
+ if (server.getConfiguration().getCloseTimeout() > 0) {
+ scheduledFuture = server.getScheduledPool().schedule(() -> {
+ long txID = tx != null ? tx.getID() : -1L;
+
+ ActiveMQServerLogger.LOGGER.sessionCloseTimeout(name, server.getConfiguration().getCloseTimeout(), consumers.size(), txID, remotingConnection, ThreadDumpUtil.threadDump());
+
+ callDoClose(failed);
Review Comment:
Resetting the context should avoid to execute pending tasks and free linked resources.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 CriticalCanalyzer to detect session.close timing out. [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev merged PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
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
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2405968008
##########
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?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406023724
##########
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?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406692463
##########
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 think I will add this on the acceptors as a property
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#issuecomment-3366337693
@brusdev I was looking into this with you..
I'm not sure yet what timeout to use.. or if I should always do this or upon configuration.
But the test I wrote simulates the condition of pending forever on storage. and this would cleanup the situation if it happened.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2413873220
##########
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:
in this particular test.. yeah..
I will add an assertion
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2407362613
##########
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:
it was too invasive on the API.. I am adding a configuration property on configuration, but I don't intend to add xml for it.. I will keep it at 30 seconds by default... ( a session should never take more than a few milliseconds to close )
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2413915007
##########
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:
LGTM
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-TBD Closing session after a configured timeout [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2406021051
##########
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5694 Closing session after a configured timeout [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #5952:
URL: https://github.com/apache/activemq-artemis/pull/5952#discussion_r2410683036
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java:
##########
@@ -1538,4 +1538,9 @@ default String resolvePropertiesSources(String propertiesFileUrl) {
default boolean isUsingDatabasePersistence() {
return getStoreConfiguration() != null && getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE;
}
+
+ /** Timeout applied when closing sessions or connections. */
+ Configuration setCloseTimeout(int timeout);
Review Comment:
I did it on purpose.. but I will remove it as we will change to use the CriticalAnalyzer
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact