Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-2729

JdbcLeaseLock won't work on SQL Server

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.12.0
    • 2.12.0
    • Broker
    • None

    Description

      When using JDBC on SQL server with HA; the broker fails during the initialization.

      $ ./artemis run
           _        _               _
          / \  ____| |_  ___ __  __(_) _____
         / _ \|  _ \ __|/ _ \  \/  | |/  __/
        / ___ \ | \/ |_/  __/ |\/| | |\___ \
       /_/   \_\|   \__\____|_|  |_|_|/___ /
       Apache ActiveMQ Artemis 2.13.0-SNAPSHOT
      
      
      2020-04-21 15:02:30,058 INFO  [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server
      2020-04-21 15:02:32,607 INFO  [org.apache.activemq.artemis.core.server] AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver,jdbcConnectionUrl=jdbc:sqlserver://localhost:1433;databaseName=amq,messageTableName=MESSAGE_TABLE,bindingsTableName=BINDINGS_TABLE,largeMessageTableName=LARGE_MESSAGES_TABLE,pageStoreTableName=PAGE_TABLE,)
      2020-04-21 15:02:32,617 INFO  [org.apache.activemq.artemis.core.server] AMQ221006: Waiting to obtain live lock
      2020-04-21 15:02:32,966 INFO  [org.apache.activemq.artemis.core.server] AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 1,073,741,824
      2020-04-21 15:02:33,113 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
      2020-04-21 15:02:33,118 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
      2020-04-21 15:02:33,121 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
      2020-04-21 15:02:33,124 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT
      2020-04-21 15:02:33,126 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-openwire-protocol]. Adding protocol support for: OPENWIRE
      2020-04-21 15:02:33,128 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
      2020-04-21 15:02:33,858 ERROR [org.apache.activemq.artemis.core.server] AMQ224000: Failure in initialisation: java.lang.IllegalStateException: com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from timestamp to TIMESTAMP is unsupported.
              at org.apache.activemq.artemis.core.server.impl.jdbc.JdbcLeaseLock.checkValidHolderId(JdbcLeaseLock.java:262) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.core.server.impl.jdbc.JdbcLeaseLock.isHeld(JdbcLeaseLock.java:216) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.core.server.impl.jdbc.JdbcNodeManager.isBackupLive(JdbcNodeManager.java:270) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation.run(SharedStoreLiveActivation.java:58) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:599) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:526) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.integration.FileBroker.start(FileBroker.java:70) [artemis-cli-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.cli.commands.Run.execute(Run.java:84) [artemis-cli-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:150) [artemis-cli-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:98) [artemis-cli-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:125) [artemis-cli-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_232]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_232]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_232]
              at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_232]
              at org.apache.activemq.artemis.boot.Artemis.execute(Artemis.java:129) [artemis-boot.jar:2.13.0-SNAPSHOT]
              at org.apache.activemq.artemis.boot.Artemis.main(Artemis.java:49) [artemis-boot.jar:2.13.0-SNAPSHOT]
      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from timestamp to TIMESTAMP is unsupported.
              at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:1112) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:3704) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:247) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:190) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2053) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2039) [mssql-jdbc-8.2.2.jre8.jar:]
              at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getTimestamp(SQLServerResultSet.java:2598) [mssql-jdbc-8.2.2.jre8.jar:]
              at org.apache.activemq.artemis.core.server.impl.jdbc.JdbcLeaseLock.checkValidHolderId(JdbcLeaseLock.java:239) [artemis-server-2.13.0-SNAPSHOT.jar:2.13.0-SNAPSHOT]
              ... 16 more
      

      Steps to reproducer:

      1. Create a SQL Server instance using podman

      #pull the sql server from docker hub
      podman pull mcr.microsoft.com/mssql/server:2017-latest
      
      #pull the sql server from docker hub
      podman run --name amq-mssql -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
       
      #Create database 'amq'
      podman exec -it amq-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password'
      
      # Create amq db using sqlcmd
      1> CREATE DATABASE amq
      2> go
      
      # verify the amq db is created using sqlcmd
      1> SELECT Name from sys.Databases
      2> go
      

      2. using broker.xml.single, this works.

          <store>
             <database-store>
                <jdbc-connection-url>jdbc:sqlserver://localhost:1433;databaseName=amq</jdbc-connection-url>
                <jdbc-user>sa</jdbc-user>
                <jdbc-password>yourStrong(!)Password</jdbc-password>
                <bindings-table-name>BINDINGS_TABLE</bindings-table-name>
                <message-table-name>MESSAGE_TABLE</message-table-name>
                <large-message-table-name>LARGE_MESSAGES_TABLE</large-message-table-name>
                <page-store-table-name>PAGE_TABLE</page-store-table-name>
                <node-manager-store-table-name>NODE_MANAGER_TABLE</node-manager-store-table-name>
                <jdbc-driver-class-name>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver-class-name>
                <jdbc-network-timeout>10000</jdbc-network-timeout>
                <jdbc-lock-renew-period>2000</jdbc-lock-renew-period>
                <jdbc-lock-expiration>15000</jdbc-lock-expiration>
                <jdbc-journal-sync-period>5</jdbc-journal-sync-period>
             </database-store>
          </store>
      

      3. using broker.xml.ha, this fails

              <ha-policy>
                  <shared-store>
                      <master>
      			<failover-on-shutdown>true</failover-on-shutdown>
                      </master>
                  </shared-store>
              </ha-policy>
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            nigro.fra@gmail.com Francesco Nigro
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m