Menu

#591 TDS Protocol error: Invalid packet type 0x11

closed
momo
7
2015-02-17
2009-09-11
sampath sam
No

We are using SQL Server 2005 SP2 with Hibernate, JTDS 1.2.2 JDBC Driver and Sun Application Server. We have a clustered
environment in the application server. One of the servers in the cluster is working fine, but the other server is not able to connect to the database and is throwing the following exception.

   05 Sep 2009 16:47:25,250  WARN httpSSLWorkerThread-80-0 AbstractBatcher:318 - Could not close a JDBC result set
    java.sql.SQLException: TDS Protocol error: Invalid packet type 0x11
            at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2314)
            at net.sourceforge.jtds.jdbc.TdsCore.getNextRow(TdsCore.java:764)
            at net.sourceforge.jtds.jdbc.JtdsResultSet.next(JtdsResultSet.java:593)
            at net.sourceforge.jtds.jdbc.JtdsResultSet.close(JtdsResultSet.java:486)
            at org.hibernate.jdbc.AbstractBatcher.closeStatements(AbstractBatcher.java:314)
            at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:382)
            at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:324)
            at org.hibernate.impl.SessionImpl.close(SessionImpl.java:298)
            at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSession(SessionFactoryUtils.java:774)
            at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.closeSession(OpenSessionInViewFilter.java:280)

Caused by: net.sourceforge.jtds.jdbc.ProtocolException: Invalid packet type 0x11
            at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2301)
            ... 43 more

05 Sep 2009 16:47:25,250  WARN httpSSLWorkerThread-80-0 AbstractBatcher:280 - exception clearing maxRows/queryTimeout
java.sql.SQLException: "Connection has been returned to pool and this reference is no longer valid.
            at net.sourceforge.jtds.jdbcx.proxy.StatementProxy.validateConnection(StatementProxy.java:688)
            at net.sourceforge.jtds.jdbcx.proxy.StatementProxy.getMaxRows(StatementProxy.java:134)
            at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:276)
            at org.hibernate.jdbc.AbstractBatcher.closeStatements(AbstractBatcher.java:330)
            at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:382)
            at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:324)
            at org.hibernate.impl.SessionImpl.close(SessionImpl.java:298)
            at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSession(SessionFactoryUtils.java:774)

Thanks,
Sampath

Discussion

  • momo

    momo - 2009-09-11

    This really looks weird. The package jTDS complains about is a TDS 7.0 NTLM authentication packet that may be send by jTDS to authenticate but should never ever be returned by a server. Could you please provide the connection configuration you are using?

     
  • sampath sam

    sampath sam - 2009-09-11

    Connection Configuration

     
  • sampath sam

    sampath sam - 2009-09-11

    Connection Configuration

     
  • sampath sam

    sampath sam - 2009-09-11

    I have attached the configuration screenshots. Please let me know if you need any other details.

     
  • sampath sam

    sampath sam - 2009-09-14

    We were facing the same error on another server also and we noticed that the error happened both times when we were trying to load an image from Database which is of BLOB type. Do you think heavy volume or size of image could cause the issue?

     
  • momo

    momo - 2009-09-15

    Sorry for my late reply, unfortunately I didn't find the time to look into this problem, yet.

    In principle, huge sized BLOBs (I've already seen values > 1GB) can be read without any problems. Which size do we talk about here?

    Anyway, my first guess would be that something (another thread) is kicking in while data is read from the server, e.g. a timeout or such. I'll try to find some time for further investigations this evening

    Cheers,
    momo

     
  • sampath sam

    sampath sam - 2009-09-15

    The maximum size of the image is 18 MB and when we tested again, the server was able to download it without any problem.

    As you said, there might be some other thread which could be causing the problem.

    Thanks for your help Holger

     
  • momo

    momo - 2009-09-16

    To be honest, I still don't have a glue what happenes in your case. To help me to narrow down the problem, could you please do the following:

    1. enable packet tracing (e.g. by passing a valid PrintWriter to DriverManager.setLogWriter()) and send me the complete log
    2. enable option "Wrap JDBC Objects"
    3. enable leak detection by setting a value for "Leak Timeout" (e.g. 10)

    Cheers,
    momo

     
  • sampath sam

    sampath sam - 2009-09-16

    The problem is we are not able to reproduce the error. Both times it happened, it occured randomly around 2 weeks after we restarted the application server.

     
  • momo

    momo - 2009-09-16

    Good grief! Please pardon the "glue" - toomanyfingersonkeyboarderror ;-)

    I have to admit from your original post I assumed you are getting this error every time your second server is trying to connect to the DB. That not being the case will make finding the error even harder. Of course writing a packet trace over a few weaks doesn't really look like a good idea...

    Even if I assume you are not allowed to, maybe you could also send me your application's sources so I can take a look? Maybe this would bring some findings...

    Cheers,
    momo

     
  • sampath sam

    sampath sam - 2009-09-16

    Sorry if I was not clear in my initial post. We get the posted error message only once and after that anytime the application tries to use the DB connection, we get "Invalid state: Connection object closed" error.
    We have 2 applications deployed in the server and I am not sure how helpful the application source code will be. Because the source code contains lots of files.

     
  • momo

    momo - 2009-09-17

    There are 2 possible ways to get the error you are seeing. First is that the SQL server indeed sends a 0x11 packet, but that doesn't make any sense as I already stated in my first post. Second possibility is that jTDS somehow gets confused with packet boundaries and reads in garbage (this could be caused by multi-threaded access to driver resources for example). It's this second possibility that I'm trying to determine and that's where your application code could help.

     
  • momo

    momo - 2009-12-07

    I'll close this bug for the time being, due to not being able to reproduce the problem. If anyone is able to safely reproduce this error I'll be glad to open it again. Meanwhile I have to assume that this has been caused by an application error, e.g. multi-threaded access to a jTDS resource other than the connection or anything.

    Cheers,
    momo

     

Log in to post a comment.