[ 
https://issues.apache.org/jira/browse/AMQ-9504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17849115#comment-17849115
 ] 

Christopher L. Shannon commented on AMQ-9504:
---------------------------------------------

Yeah, it would be a problem because it's trying to create duplicate adapters 
touching the same directory, so it's definitely not going to work right. 
Turning off JMX as you have shown just pushes the problem downstream if you 
configure things that way and will cause things to break. The vast majority of 
people do not use multiKahaDB and if they do obviously don't configure it this 
way (most people that use the option to create a store per destination set up 
their config with that as the only filter) otherwise it would have been 
reported way before now.

Is there a reason why you can't build a custom version with the patch 
temporarily? One of the benefits of using open source like this is you can do 
whatever you want, you can build your own version at any point. I know you want 
to use an official release but building your own version with the fix is the 
fastest way for now.

Our plan is to do a 6.2.0 release in the next couple of weeks, after that we 
could look at doing a 5.18.5 release which would include this fix, but again, 
I'm not really sure on an exact timeline so if it's that high of a priority you 
will need to build your own version temporarily until the new version is out.

> 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)

Reply via email to