Assure the release of an application lock

  • Hello,

    we have a long running procedure that should not run parallel. If it runs in a transaction we get problems with the transaction log, so we decided to use an application lock

    sp_getapplock

    At the end of the procedure the lock is released, also if errors occure that we can catch.

    sp_releaseapplock

    The Problem: when somebody aborts the procedure, that application lock will stay alive. How can we handle this best? Maybe there is a way to determine and displace "zombie locks" at the begin of the procedure?

    Thanks!

    Tobias

  • You could try putting sp_releaseapplock in the CATCH block as well as the TRY block.

    As you seem to be using SESSION applocks I think you would have difficulty is determining which ones are 'zombies'.

  • if you have only problem of calling procedures by mutlipul users then use NOLOCK in your query.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply