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