Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 4.1.0
    • Fix Version/s: NEEDS_REVIEW
    • Component/s: Broker
    • Labels:
      None
    • Environment:

      Windows 2000, SQL 2005

      Description

      1. Create DB for ActiveMQ
      2. Start broker using jtds SQL 2005 driver.
      3. Exception:
      2006-12-27 11:08:48,796 [main ] INFO JDBCPersistenceAdapter - Database driver recognized: [jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase]
      2006-12-27 11:08:48,983 [main ] INFO DefaultDatabaseLocker - Attempting to acquire the exclusive lock to become the Master broker
      2006-12-27 11:08:48,983 [main ] ERROR DefaultDatabaseLocker - Failed to acquire lock: java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
      java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
      at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
      at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
      at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
      at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
      at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:525)
      at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:487)
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(JtdsPreparedStatement.java:475)
      at org.apache.activemq.store.jdbc.DefaultDatabaseLocker.start(DefaultDatabaseLocker.java:59)
      at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:175)
      at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1251)
      at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1209)
      at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:508)
      at org.apache.activemq.broker.BrokerService.start(BrokerService.java:394)
      at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:47)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
      at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:161)
      at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:51)
      at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:41)
      at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:57)
      at org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:82)
      at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:47)
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
      at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:65)
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
      at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:46)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.activemq.console.Main.runTaskClass(Main.java:159)
      at org.apache.activemq.console.Main.main(Main.java:91)

        Activity

        Hide
        james strachan added a comment -

        It looks like SQL Server does not support the exclusive locking syntax for JDBC Master/Slave.

        As a workaround you can add the following property to your activemq.xml...

        <journaledJDBC useDatabaseLock="true" ...>...

        I've just patched 4.2 so that it should work without this workaround; see AMQ-1191 for more details

        Show
        james strachan added a comment - It looks like SQL Server does not support the exclusive locking syntax for JDBC Master/Slave. As a workaround you can add the following property to your activemq.xml... <journaledJDBC useDatabaseLock="true" ...>... I've just patched 4.2 so that it should work without this workaround; see AMQ-1191 for more details
        Hide
        Andreas Guther added a comment -

        I had the described problem while using version 4.1.1. Finally I found this issue. Using the workaround as described above did not solve my problem.

        But after changing <journaledJDBC useDatabaseLock="true" ...> to <journaledJDBC useDatabaseLock="false" ...> I could get the JDBC Persistence to work.

        Show
        Andreas Guther added a comment - I had the described problem while using version 4.1.1. Finally I found this issue. Using the workaround as described above did not solve my problem. But after changing <journaledJDBC useDatabaseLock="true" ...> to <journaledJDBC useDatabaseLock="false" ...> I could get the JDBC Persistence to work.
        Hide
        Hondong added a comment -

        Hello.

        I don´t think, that this Issue is fixed because:

        deactivating the lock Database option works for, but even the Slave will become online.
        If both were Online using the same Database, you get Problems with the Messages produced on the slave or the master.
        You will get an inconsitent state.
        The Master did not recocognize Messages produced on the Slave and the other way arround.

        Kind regards,

        Nils Hondong

        Show
        Hondong added a comment - Hello. I don´t think, that this Issue is fixed because: deactivating the lock Database option works for, but even the Slave will become online. If both were Online using the same Database, you get Problems with the Messages produced on the slave or the master. You will get an inconsitent state. The Master did not recocognize Messages produced on the Slave and the other way arround. Kind regards, Nils Hondong
        Hide
        hiskill added a comment -

        I am using 5.3.0 deployed as EAR/RAR on JBoss. I don't have the setting useDatabaseLock="true" in the broker-config.xml.

        With MSSQL 2000 and MSSQL 2005 it works fine but with MSSQL 2008 I keep getting these messages, broker never starts up.

        2009-11-12 21:51:15,992 INFO [STDOUT] 2009-11-12 21:51:15,992 [ActiveMQ Broker] INFO DefaultDatabaseLocker - Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...

        Looks like the ACTIVEMQ_MSGS table is not getting created where as ACTIVEMQ_ACKS & ACTIVEMQ_LOCK tables are created.

        Even with useDatabaseLock="true", broker doesn't come up. Any idea when this fix is expected?

        Show
        hiskill added a comment - I am using 5.3.0 deployed as EAR/RAR on JBoss. I don't have the setting useDatabaseLock="true" in the broker-config.xml. With MSSQL 2000 and MSSQL 2005 it works fine but with MSSQL 2008 I keep getting these messages, broker never starts up. 2009-11-12 21:51:15,992 INFO [STDOUT] 2009-11-12 21:51:15,992 [ActiveMQ Broker] INFO DefaultDatabaseLocker - Failed to acquire lock. Sleeping for 1000 milli(s) before trying again... Looks like the ACTIVEMQ_MSGS table is not getting created where as ACTIVEMQ_ACKS & ACTIVEMQ_LOCK tables are created. Even with useDatabaseLock="true", broker doesn't come up. Any idea when this fix is expected?
        Hide
        hiskill added a comment -

        I tried creating ACTIVEMQ_MSGS manually as well. So I don't know if there is any workaround for this problem. Pleaese let us know.

        Show
        hiskill added a comment - I tried creating ACTIVEMQ_MSGS manually as well. So I don't know if there is any workaround for this problem. Pleaese let us know.
        Hide
        Gary Tully added a comment -

        HiSkill,
        so is your problem that the messages table create fails? if so, what is the error you get?
        If not, is your problem with the locker implementation. If so, do you know what will work? the locker implementation can be overridden on an adapter basis by adding an implementation reference to the finder resource location. see: http://svn.apache.org/viewvc/activemq/tags/activemq-5.3.0/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc/lock/microsoft_sql_server_2005_jdbc_driver?view=markup for the microsoft_sql_server_2005_jdbc_driver override from the default.
        You can implement your own and have it picked up by adding the corresponding resource to the classpath.

        Show
        Gary Tully added a comment - HiSkill, so is your problem that the messages table create fails? if so, what is the error you get? If not, is your problem with the locker implementation. If so, do you know what will work? the locker implementation can be overridden on an adapter basis by adding an implementation reference to the finder resource location. see: http://svn.apache.org/viewvc/activemq/tags/activemq-5.3.0/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc/lock/microsoft_sql_server_2005_jdbc_driver?view=markup for the microsoft_sql_server_2005_jdbc_driver override from the default. You can implement your own and have it picked up by adding the corresponding resource to the classpath.
        Hide
        hiskill added a comment -

        Thanks for the quick reply Gary.

        As I mentioned, I saw the problem only with MSSQL 2008.

        Here is our configuration:

        • we deployed activemq as RAR on JBoss
        • currently we have only one broker configured but at some point we will add more brokers
        • we didn't explicitly set "useDatabaseLock" property in the broker-config.xml

        Couple of problems
        1. when the broker starts for the first time ACTIVEMQ_ACKS & ACTIVEMQ_LOCK tables are created but ACTIVEMQ_MSGS is not created
        2. getting "Failed to acquire lock" errors continusly

        So I tried creating ACTIVEMQ_MSGS manually and restarted the broker, still get the "Failed to acquire lock" errors continusly

        Only way to get this working is to set property useDatabaseLock="false", this will work fine with one broker as for multiple brokers lock is needed.

        Please let me know if there is a workaround for our problem.

        Here is the part of stacktrace:

        Reason: java.io.IOException: Failed to get last broker message id: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'ACTIVEMQ_MSGS'.
        java.io.IOException: Failed to get last broker message id: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'ACTIVEMQ_MSGS'.
        at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33)
        at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getLastMessageBrokerSequenceId(JDBCPersistenceAdapter.java:170)
        at org.apache.activemq.store.journal.JournalPersistenceAdapter.getLastMessageBrokerSequenceId(JournalPersistenceAdapter.java:212)
        at org.apache.activemq.broker.region.DestinationFactoryImpl.getLastMessageBrokerSequenceId(DestinationFactoryImpl.java:140)
        at org.apache.activemq.broker.region.RegionBroker.<init>(RegionBroker.java:106)
        at org.apache.activemq.broker.jmx.ManagedRegionBroker.<init>(ManagedRegionBroker.java:94)
        at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1695)
        at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1689)
        at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1649)
        at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:667)
        at org.apache.activemq.broker.BrokerService.getAdminConnectionContext(BrokerService.java:1866)
        at org.apache.activemq.broker.BrokerService.startDestinations(BrokerService.java:1853)
        at org.apache.activemq.broker.BrokerService.start(BrokerService.java:450)
        at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:56)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

        Show
        hiskill added a comment - Thanks for the quick reply Gary. As I mentioned, I saw the problem only with MSSQL 2008. Here is our configuration: we deployed activemq as RAR on JBoss currently we have only one broker configured but at some point we will add more brokers we didn't explicitly set "useDatabaseLock" property in the broker-config.xml Couple of problems 1. when the broker starts for the first time ACTIVEMQ_ACKS & ACTIVEMQ_LOCK tables are created but ACTIVEMQ_MSGS is not created 2. getting "Failed to acquire lock" errors continusly So I tried creating ACTIVEMQ_MSGS manually and restarted the broker, still get the "Failed to acquire lock" errors continusly Only way to get this working is to set property useDatabaseLock="false", this will work fine with one broker as for multiple brokers lock is needed. Please let me know if there is a workaround for our problem. Here is the part of stacktrace: Reason: java.io.IOException: Failed to get last broker message id: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'ACTIVEMQ_MSGS'. java.io.IOException: Failed to get last broker message id: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'ACTIVEMQ_MSGS'. at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33) at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getLastMessageBrokerSequenceId(JDBCPersistenceAdapter.java:170) at org.apache.activemq.store.journal.JournalPersistenceAdapter.getLastMessageBrokerSequenceId(JournalPersistenceAdapter.java:212) at org.apache.activemq.broker.region.DestinationFactoryImpl.getLastMessageBrokerSequenceId(DestinationFactoryImpl.java:140) at org.apache.activemq.broker.region.RegionBroker.<init>(RegionBroker.java:106) at org.apache.activemq.broker.jmx.ManagedRegionBroker.<init>(ManagedRegionBroker.java:94) at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1695) at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1689) at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1649) at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:667) at org.apache.activemq.broker.BrokerService.getAdminConnectionContext(BrokerService.java:1866) at org.apache.activemq.broker.BrokerService.startDestinations(BrokerService.java:1853) at org.apache.activemq.broker.BrokerService.start(BrokerService.java:450) at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:56) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
        Hide
        Timothy Bish added a comment -

        4.x broker series is EOL.

        Show
        Timothy Bish added a comment - 4.x broker series is EOL.

          People

          • Assignee:
            Unassigned
            Reporter:
            Artem
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development