1 Reply Latest reply on Jan 8, 2010 12:19 AM by Yong Hao Gao

    Messaging problem when using MS SQLServer

    Brian Bek Jensen Newbie

      Hello

       

      I have the following setup:

       

      JBoss AS with tag JBPAPP_4_3_0_GA_CP02 connected to MS SQLServer. DefaultDS and all other database needs have been set to use the SQLServer.

       

      The specific Messaging version is JBossMessaging 1.4.0 SP3 CP03.

       

      When restarting the server we often experience that the following error/stacktrace occurs:

       

      2010-01-06 14:58:10,545 WARN  [org.jboss.messaging.core.impl.JDBCSupport] SQLException caught, SQLState null code:0- assuming deadlock detected, try:1
      com.microsoft.sqlserver.jdbc.SQLServerException: The data has been accessed and is not available for this column or parameter.
          at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:1959)
          at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:175)
          at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:113)
          at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1982)
          at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1977)
          at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getStream(SQLServerResultSet.java:1989)
          at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getBinaryStream(SQLServerResultSet.java:2064)
          at org.jboss.resource.adapter.jdbc.WrappedResultSet.getBinaryStream(WrappedResultSet.java:357)
          at org.jboss.messaging.core.impl.JDBCPersistenceManager.getBytes(JDBCPersistenceManager.java:2488)
          at org.jboss.messaging.core.impl.JDBCPersistenceManager$1GetMessageListTX.doTransaction(JDBCPersistenceManager.java:563)
          at org.jboss.messaging.core.impl.JDBCPersistenceManager$1GetMessageListTX.doTransaction(JDBCPersistenceManager.java:485)
          at org.jboss.messaging.core.impl.JDBCSupport$JDBCTxRunner2.execute(JDBCSupport.java:474)
          at org.jboss.messaging.core.impl.JDBCSupport$JDBCTxRunner2.executeWithRetry(JDBCSupport.java:512)
          at org.jboss.messaging.core.impl.JDBCPersistenceManager.getMessages(JDBCPersistenceManager.java:602)
          at org.jboss.messaging.core.impl.PagingChannelSupport.processReferences(PagingChannelSupport.java:565)
          at org.jboss.messaging.core.impl.PagingChannelSupport.doLoad(PagingChannelSupport.java:498)
          at org.jboss.messaging.core.impl.PagingChannelSupport.load(PagingChannelSupport.java:211)
          at org.jboss.jms.server.destination.QueueService.startService(QueueService.java:105)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
          at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:196)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:995)
          at $Proxy0.start(Unknown Source)
          at org.jboss.system.ServiceController.start(ServiceController.java:417)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at org.jboss.system.ServiceController.start(ServiceController.java:435)
          at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy4.start(Unknown Source)
          at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy51.start(Unknown Source)
          at org.jboss.deployment.XSLSubDeployer.start(XSLSubDeployer.java:197)
          at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
          at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy9.deploy(Unknown Source)
          at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
          at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
          at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
          at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
          at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
          at $Proxy0.start(Unknown Source)
          at org.jboss.system.ServiceController.start(ServiceController.java:417)
          at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy4.start(Unknown Source)
          at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
          at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy5.deploy(Unknown Source)
          at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
          at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
          at org.jboss.Main.boot(Main.java:200)
          at org.jboss.Main$1.run(Main.java:508)
          at java.lang.Thread.run(Thread.java:595)

       

       

      When this happens the database is impossible to get back to normal, so we delete it and start over again! This is not good in a production environment :-)

       

      Googling around I found the following snippet on Microsofts website (link: http://msdn.microsoft.com/en-us/library/bb879937.aspx):

       

      -----------------------------------------------------------------------------

      Retrieving Large Data with Adaptive Buffering

       

      When large values are read once by using the get<Type>Stream methods, and the ResultSet columns and the CallableStatement OUT parameters are accessed in the order returned by the SQL Server, adaptive buffering minimizes the application memory usage when processing the results. When using adaptive buffering:

       

      The get<Type>Stream methods defined in the SQLServerResultSet and SQLServerCallableStatement classes return read-once streams by default, although the streams can be reset if marked by the application. If the application wants to reset the stream, it has to call the mark method on that stream first.

       

      The get<Type>Stream methods defined in the SQLServerClob and SQLServerBlob classes return streams that can always be repositioned to the start position of the stream without calling the mark method.

       

      When the application uses adaptive buffering, the values retrieved by the get<Type>Stream methods can only be retrieved once. If you try to call any get<Type> method on the same column or parameter after calling the get<Type>Stream method of the same object, an exception is thrown with the message, "The data has been accessed and is not available for this column or parameter".

      -----------------------------------------------------------------------------

       

      Looking at the code in the Java class (JDBCPersistenceManager), which can be seen here:

      http://anonsvn.jboss.org/repos/messaging/tags/JBossMessaging_1_4_0_SP3_CP03/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java


      I see the following (in the getBytes method):

      ...

               try
               {
                  InputStream i = rs.getBinaryStream(columnIndex);

       

                  if (i == null) { return null; }

       

      *           is = new BufferedInputStream(rs.getBinaryStream(columnIndex),
                        BUFFER_SIZE);

       

                  os = new ByteArrayOutputStream(BUFFER_SIZE);

      ...

      The * (line 2488) marks the spot that is reported as where the error occurs. So I wonder if it is the extra call of "getBinaryStream" that is the cause? As I read the code the extra call is not neccessary as the variable "i" could be used instead.

       

      The code does not change in later versions until version 2 where everything changes...

       

      Have anybody experienced this also, and is the suspicion that the extra call to getBinaryStream is the cause of the error correct and if so should I create a Jira issue?

       

      Regards Brian