[
https://issues.apache.org/jira/browse/AMQ-9504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848442#comment-17848442
]
Justin Bertram edited comment on AMQ-9504 at 5/23/24 8:02 PM:
--------------------------------------------------------------
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.
bq. 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:
bq. 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."
Nowhere in the document, it says that if you use a filteredKahaDB with
perDestination="true" then you can not use any other filteredKahaDB and more
over the use case I mentioned is a valid one where I have non durable topics
and I do not want to run multiple kahadbs for each topics, where as for queues
I want to have one kahadb per queue.
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 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."
Nowhere in the document, it says that if you use a filteredKahaDB with
perDestination="true" then you can not use any other filteredKahaDB and more
over the use case I mentioned is a valid one where I have non durable topics
and I do not want to run multiple kahadbs for each topics, where as for queues
I want to have one kahadb per queue.
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
> Assignee: Christopher L. Shannon
> Priority: Major
> Fix For: 6.2.0, 5.18.5, 6.1.3
>
> Attachments: bugfix.patch, test.patch
>
>
> When using Multi KahaDB persistence adapter according to [the
> 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:xml}
> <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:
> {noformat}
> [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){noformat}
> 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 the broker, 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 MBean 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)