Results 1 to 7 of 7
  1. #1
    Looserette is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Sybase jdbc2 lock

    Hello all,

    This is probably a bit too specific to get any help at all, but I'm really stuck here - almost as much as my threads ! ;)

    So, first a few details:
    I'm working on Solaris Sparc 5.10.
    I'm playing with java, connecting to a Sybase DB - to be more accurate: it's the DB used by Netcool. For those who don't know Netcool, just leave it at "it's a Sybase DB".


    So, I'm opening 2 threads to update alarms (= to update the DB), with a standard "update" query - nothing fancy there.

    After some time of running (between 30min and 3 days), my threads get locked.
    Here's an extract of a java thread dump:


    "Thread-3" prio=3 tid=0x00294248 nid=0xf in Object.wait() [0xb38ff000..0xb38ffc70]
    at java.lang.Object.wait(Native Method)
    - waiting on <0xb863bee0> (a com.sybase.jdbc2.timedio.ResponseQueue)
    at com.sybase.jdbc2.utils.SyncQueue.take(SyncQueue.ja va:84)
    - locked <0xb863bee0> (a com.sybase.jdbc2.timedio.ResponseQueue)
    at com.sybase.jdbc2.utils.SyncObj.giveToMe(SyncObj.ja va:41)
    at com.sybase.jdbc2.timedio.InStreamMgr.takeIfNoReadA head(InStreamMgr.java:655)
    at com.sybase.jdbc2.timedio.InStreamMgr.cacheResponse s(InStreamMgr.java:584)
    at com.sybase.jdbc2.timedio.OutStreamMgr.beginRequest (OutStreamMgr.java:207)
    at com.sybase.jdbc2.tds.Tds.language(Tds.java:751)
    at com.sybase.jdbc2.jdbc.SybStatement.sendQuery(SybSt atement.java:1522)
    at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(S ybStatement.java:1696)
    at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(S ybStatement.java:441)
    at runQuery.run(SQL_server.java:438)
    at java.lang.Thread.run(Thread.java:595)

    "Thread-2" prio=3 tid=0x00293d40 nid=0xe in Object.wait() [0xb39ff000..0xb39ffbf0]
    at java.lang.Object.wait(Native Method)
    - waiting on <0xb863bec8> (a com.sybase.jdbc2.timedio.RequestObj)
    at com.sybase.jdbc2.utils.SyncQueue.take(SyncQueue.ja va:84)
    - locked <0xb863bec8> (a com.sybase.jdbc2.timedio.RequestObj)
    at com.sybase.jdbc2.utils.SyncObj.giveToMe(SyncObj.ja va:41)
    at com.sybase.jdbc2.timedio.RequestObj.giveToMe(Reque stObj.java:54)
    at com.sybase.jdbc2.timedio.OutStreamMgr.getSendLock( OutStreamMgr.java:102)
    at com.sybase.jdbc2.tds.Tds.language(Tds.java:746)
    at com.sybase.jdbc2.jdbc.SybStatement.sendQuery(SybSt atement.java:1522)
    at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(S ybStatement.java:1696)
    at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(S ybStatement.java:441)
    at runQuery.run(SQL_server.java:438)
    at java.lang.Thread.run(Thread.java:595)

    As you can see, my 2 threads are locked. One at RequestObj, the other at ResponseQueue.
    My guess is that somehow the DB is a bit slow to respond/overloaded (crappy old server), and the whole thing gets stuck.

    It seems that the default timeouts in the JDBC are not working - otherwise, they would trigger an exception, which would (hopefully:)) be handled.


    So, I'd like to somehow add some timeouts somewhere to avoid this locking ... but I have no idea where to start, since the thread itself is locked (might be a way to start a 2nd thread that would check timeouts and kill the locked thread ?).

    Any help would be much appreciated there.






    Here is the jdbc version I'm using:
    bash-3.00# head jconn2.jar
    PK
    Main-Class: SybVersion
    Created-By: 1.2fcs (Sun Microsystems Inc.)

    Name: com/sybase/jdbc2/tds
    Specification-Title: "jConnect for JDBC 2.0"
    Implementation-Version: "Build (25827)"
    Specification-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Title: "com.sybase.jdbc2.tds"
    bash-3.00# head -100 jconn2.jar
    PK
    Main-Class: SybVersion
    Created-By: 1.2fcs (Sun Microsystems Inc.)

    Name: com/sybase/jdbc2/tds
    Specification-Title: "jConnect for JDBC 2.0"
    Implementation-Version: "Build (25827)"
    Specification-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Title: "com.sybase.jdbc2.tds"
    Implementation-Vendor: "Sybase, Inc."

    Name: com/sybase/jdbc2/utils
    Specification-Title: "jConnect for JDBC 2.0"
    Implementation-Version: "Build (25827)"
    Specification-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Title: "com.sybase.jdbc2.utils"
    Implementation-Vendor: "Sybase, Inc."

    Name: com/sybase/jdbc2/jdbc
    Specification-Title: "jConnect for JDBC 2.0"
    Implementation-Version: "Build (25827)"
    Specification-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Title: "com.sybase.jdbc2.jdbc"
    Implementation-Vendor: "Sybase, Inc."

    Name: com/sybase/jdbc2/timedio
    Specification-Title: "jConnect for JDBC 2.0"
    Implementation-Version: "Build (25827)"
    Specification-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Title: "com.sybase.jdbc2.timedio"
    Implementation-Vendor: "Sybase, Inc."

    Name: com/sybase/jdbcx/
    Specification-Title: "jConnect for JDBC 2.0"
    Specification-Vendor: "Sybase, Inc."
    Implementation-Vendor: "Sybase, Inc."
    Specification-Version: "5.5"
    Implementation-Version: "Build (25827)"
    Implementation-Title: "com.sybase.jdbcx"

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Sybase jdbc2 lock

    Moved from Advanced Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Sybase jdbc2 lock

    Do you know what update is happening in each of those cases?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Looserette is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: Sybase jdbc2 lock

    Quote Originally Posted by Tolls View Post
    Do you know what update is happening in each of those cases?
    actually, the answer is "yes-ish":
    the program does only one query, with different values for each variable at each run.
    The query being:

    query = "update alerts.status set CircuitID='"+CIR_ID+"',FECircuitID='"+CIR_ID+"',FE City='"+FECity+"',Impact="+Impact+",FECircuitStatu s='"+STS_CIR+"',FECustomerName='"+CUS_NME+"',FEEqu ipType='"+TYP_FAC+"' where Serial="+Serial+";";

    (note: Serial being "obviously" unique)
    I tried to delete the specific row before its update, and the system coped well with it (the update launch return 2 instead of 1).

    Although, it may happen that the row is being deleted at exactly the same time as when the update is being fired - I have not been able to test that particular case, and thinking on it, that might be the issue (or not!)

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Sybase jdbc2 lock

    You'll need to note the 'serials' being used then, if they're not already logged.
    Also see whether transactions are being held onto longer than necessary.
    I don't know how Sybase handles locks, so I can't suggest exactly what to look for. If you can I'd try and track down any article on it you can, just to see what possible scenarios can cause a deadlock for you.

    Oh, and unrealted to your problem, but that should be a PreparedStatement shouldn't it? Or does Sybase handle binding differently?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Looserette is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: Sybase jdbc2 lock

    Quote Originally Posted by Tolls View Post
    You'll need to note the 'serials' being used then, if they're not already logged.
    Also see whether transactions are being held onto longer than necessary.
    I don't know how Sybase handles locks, so I can't suggest exactly what to look for. If you can I'd try and track down any article on it you can, just to see what possible scenarios can cause a deadlock for you.

    Oh, and unrealted to your problem, but that should be a PreparedStatement shouldn't it? Or does Sybase handle binding differently?
    Well, I already tried to look for infos on deadlock when using the JDBC for Sybase, but I could not find anything relevant.

    And yes, this could/should be a preparedstatement ... I need to change many things in the code to make things better ;)

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Sybase jdbc2 lock

    What happens in a typical transaction, prior to commit?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 3
    Last Post: 05-24-2011, 09:52 PM
  2. lock on class
    By rajinder5 in forum New To Java
    Replies: 0
    Last Post: 10-13-2010, 11:08 AM
  3. Java + Sybase + Oracle
    By xxAlemanxx in forum Advanced Java
    Replies: 1
    Last Post: 06-26-2008, 08:41 AM
  4. S.O.S SyBase Connection
    By Marty in forum JDBC
    Replies: 2
    Last Post: 05-14-2007, 05:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •