gemmellr commented on code in PR #5173: URL: https://github.com/apache/activemq-artemis/pull/5173#discussion_r1734935331
########## artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AckManager.java: ########## @@ -149,15 +149,32 @@ public boolean initRetry() { HashMap<SimpleString, LongObjectHashMap<JournalHashMap<AckRetry, AckRetry, Queue>>> retries = sortRetries(); + scanAndFlushMirrorTargets(); + if (retries.isEmpty()) { logger.trace("Nothing to retry!, server={}", server); return false; } - progress = new MultiStepProgress(sortRetries()); + progress = new MultiStepProgress(retries); return true; } + private void scanAndFlushMirrorTargets() { + logger.debug("scanning and flushing mirror targets"); + // this will navigate on each connection, find the connection that has a mirror controller, and call flushMirrorTarget for each MirrorTargets. (it should be 1 in most cases) + // An alternative design instead of going through the connections, would be to register the MirrorTargets within the AckManager, however to avoid memory leaks after disconnects and reconnects it is safer to + // scan through the connections + server.getRemotingService().getConnections().stream(). + filter(c -> c instanceof ActiveMQProtonRemotingConnection && ((ActiveMQProtonRemotingConnection) c).getAmqpConnection().getMirrorControllerTargets() != null). + forEach(c -> ((ActiveMQProtonRemotingConnection) c).getAmqpConnection().getMirrorControllerTargets().forEach(this::flushMirrorTarget)); Review Comment: This might work for now, but anyone with lots of connections seems likely to find this causes a noticable amount of CPU usage. Per other comment, its also already a leak of sorts...and if leaking could lead to 'wait + flush' on stale targets. -- 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-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For additional commands, e-mail: gitbox-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact