You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ritesh adval (Jira)" <ji...@apache.org> on 2024/05/22 04:55:00 UTC
[jira] [Comment Edited] (AMQ-9504) activemq multikahadb persistence adapter with topic wildcard filtered adapter and per destination filtered adapter causes broker failure on restart
[ https://issues.apache.org/jira/browse/AMQ-9504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848442#comment-17848442 ]
ritesh adval edited comment on AMQ-9504 at 5/22/24 4:54 AM:
------------------------------------------------------------
It is if you look at the documentation at [https://activemq.apache.org/components/classic/documentation/kahadb] , first of all multiple filteredKahaDB are allowed as also shown in the example in above link.
"Each instance of {{kahaDB}} can be configured independently. If no destination is supplied to a {{{}filteredKahaDB{}}}, the implicit default value will match any destination, queue or topic." This is a handy catch all. If no matching persistence adapter can be found, destination creation will fail with an exception. The {{filteredKahaDB}} shares its wildcard matching rules with [Per Destination Policies|https://activemq.apache.org/components/classic/documentation/per-destination-policies].
and also:
"Set {{perDestination="true"}} on the catch all, i.e., when no explicit destination is set, {{filteredKahaDB}} entry. Each matching destination will be assigned its own {{kahaDB}} instance."
And I tested it and it works just not on restart of the broker due the bug and fix seems to have fixed the issue.
was (Author: JIRAUSER305516):
It is as if you look at the documentation at [https://activemq.apache.org/components/classic/documentation/kahadb] , first of all multiple filteredKahaDB are allowed as also shown in the example in above link.
"Each instance of {{kahaDB}} can be configured independently. If no destination is supplied to a {{{}filteredKahaDB{}}}, the implicit default value will match any destination, queue or topic." This is a handy catch all. If no matching persistence adapter can be found, destination creation will fail with an exception. The {{filteredKahaDB}} shares its wildcard matching rules with [Per Destination Policies|https://activemq.apache.org/components/classic/documentation/per-destination-policies].
and also:
"Set {{perDestination="true"}} on the catch all, i.e., when no explicit destination is set, {{filteredKahaDB}} entry. Each matching destination will be assigned its own {{kahaDB}} instance."
And I tested it and it works just not on restart of the broker due the bug and fix seems to have fixed the issue.
> activemq multikahadb persistence adapter with topic wildcard filtered adapter and per destination filtered adapter causes broker failure on restart
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: AMQ-9504
> URL: https://issues.apache.org/jira/browse/AMQ-9504
> Project: ActiveMQ Classic
> Issue Type: Bug
> Components: Broker
> Affects Versions: 5.18.4, 6.1.2
> Reporter: ritesh adval
> Priority: Major
> Attachments: bugfix.patch, test.patch
>
>
> when using Multikahadb persistence adapter per documentation : [https://activemq.apache.org/components/classic/documentation/kahadb] it shows that you can use multiple filteredPersistenceAdapters but this does not work if you have two filtered adapter where one is using wildcard match for topics (or even a specific topic) and second filtered adapter using per destination filtered adapter.
> The idea being you want to use one kahadb instance for all the topics and per destination kahadb instance for all other destinations like queues. Something like this for illustration of the issue see test for more details. (note jmx needs to be enabled) :
> {code:java}
> <broker useJmx="true" brokerName="broker">
> <persistenceAdapter>
> <mKahaDB directory="${activemq.base}/data/kahadb">
> <filteredPersistenceAdapters>
> <!-- match all topics-->
> <filteredKahaDB topic=">">
> <usage>
> <storeUsage limit="1g" />
> </usage>
> <persistenceAdapter>
> <kahaDB journalMaxFileLength="32mb"/>
> </persistenceAdapter>
> </filteredKahaDB>
> <!-- match all destinations kahaDB per destinations -->
> <filteredKahaDB perDestination="true">
> <persistenceAdapter>
> <kahaDB journalMaxFileLength="32mb"/>
> </persistenceAdapter>
> </filteredKahaDB>
> </filteredPersistenceAdapters>
> </mKahaDB>
> </persistenceAdapter>
> </broker> {code}
> With this setting it works for the first time when broker is started. But as soon as you have atleast one topic created which uses wild card filtered adapter and you restart the broker, then what happens is there are two KahaDBPersistenceAdapter created one by the wildcard (">") topic filtered adapter and another one by the second per destination filtered adapter, and so second KahaDBPersistenceAdapter fails with below exception:
>
> [INFO] Running org.apache.activemq.bugs.MultiKahaDBMultipleFilteredAdapterTest
> [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 16.20 s <<< FAILURE! – in org.apache.activemq.bugs.MultiKahaDBMultipleFilteredAdapterTest
> [ERROR] org.apache.activemq.bugs.MultiKahaDBMultipleFilteredAdapterTest.testTopicWildcardAndPerDestinationFilteredAdapter – Time elapsed: 11.08 s <<< ERROR!
> javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=localhost,service=PersistenceAdapter,instanceName=KahaDBPersistenceAdapter[/mnt/c/Users/ritesh.adval/work/external-repos/activemq/activemq-unit-tests/target/activemq-data/mKahaDB/topic#3a#2f#2f#3e_Index_/mnt/c/Users/ritesh.adval/work/external-repos/activemq/activemq-unit-tests/target/activemq-data/mKahaDB/topic#3a#2f#2f#3e|#3a#2f#2f#3e_Index_/mnt/c/Users/ritesh.adval/work/external-repos/activemq/activemq-unit-tests/target/activemq-data/mKahaDB/topic#3a#2f#2f#3e]
> at java.management/com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:436)
> at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1855)
> at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:955)
> at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:890)
> at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:320)
> at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
> at org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:415)
> at org.apache.activemq.broker.jmx.AnnotatedMBean.registerMBean(AnnotatedMBean.java:93)
> at org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter.doStart(KahaDBPersistenceAdapter.java:251)
> at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)
> at org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter.doStart(MultiKahaDBPersistenceAdapter.java:381)
> at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)
> at org.apache.activemq.broker.BrokerService.doStartPersistenceAdapter(BrokerService.java:681)
> at org.apache.activemq.broker.BrokerService.startPersistenceAdapter(BrokerService.java:663)
> at org.apache.activemq.broker.BrokerService.start(BrokerService.java:627)
> at org.apache.activemq.bugs.MultiKahaDBMultipleFilteredAdapterTest.testTopicWildcardAndPerDestinationFilteredAdapter(MultiKahaDBMultipleFilteredAdapterTest.java:76)
>
> I have unit test for this and have a fix as well, attaching them with the issue (its for 5.18.4 release and I believe issue exists in latest 6.x release as well).
>
> the bug is that on restart/start of activemq, wildcard filtered adapter adds one KahaDBPersistenceAdapter when calling MultiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters, and on the call to doStart of MultiKahaDBPersistenceAdapter, it uses per destination filtered adapter to add another KahaDBPersistenceAdapter for the same topic, and fails on jmx bean registration. The fix is to make sure to check if a KahaDBPersistenceAdapter already exists for given destination dir, when we do per destination filtered adapter processing and only add it if one does not exists already.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)