Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    2

    Unanswered: sp_getapplock returns -999

    Hi everyone

    I have a problem, don't we all It's in regards to the sp_getappllock stored procedure. Every once in a while it fails with a -999 return code value. According to the Microsoft documentation, that's a "Parameter validation or other call error". Retrying the call later works.

    It takes four arguments:
    - the application resource that is being locked. A string value up to 255 characters.
    - the lock mode, can be one of these values: Shared, Update, Exclusive, IntentExclusive, IntentShared.
    - the lock owner, Transaction (the default), or Session.
    - a timeout value in milliseconds.

    In my code, the last three arguments, are literals, so as the code works most of the time, they are unlikely to be the cause of the problem.

    The first parameter is a concatenation of two numbers separated by a colon. For example, a resource that it failed was 767:1

    A further piece of information is that the code is written in Java and uses Microsoft's JDBC Beta 2 drivers.

    Does anyone have any clues on what is happening here ?

    Regards
    Patrick

  2. #2
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    2
    Found the answer.

    The problem was caused by code that was not thread-safe. The -999 was indicating that their was no active transaction (worked this out by looking at the source for sp_getapplock).

    Two threads were sharing the same database connection (which I must admit, I wasn't aware off). One thread was just closing the connection, just before the other executed the query. Ouch.

    Regards
    Patrick

Posting Permissions

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