Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1985

Re: Using sp_getapplock outside a transaction

Newsgroups comp.databases.ms-sqlserver
Date 2017-11-25 16:21 -0800
References <20171125145629.a8f9f75371e03662bf0496dd@gmail.com> <e7eeb2b3-4502-4512-a2c8-a20e908fa080@googlegroups.com> <20171125182411.7cc99cc41acef664ea224b1c@gmail.com> <61564775-2d20-45eb-bb52-ad5f420e569d@googlegroups.com> <20171125211302.4e22ff4f9d06e890a9494fc9@gmail.com>
Message-ID <182290b7-b27a-41a4-a359-32e59b6fe25a@googlegroups.com> (permalink)
Subject Re: Using sp_getapplock outside a transaction
From rja.carnegie@gmail.com

Show all headers | View raw


On Saturday, 25 November 2017 18:13:02 UTC, Anton Shepelev  wrote:
> rja.carnegie:
> 
> > While  replying,  I noticed that sp_releaseapplock
> > takes @LockOwner as well.  So perhaps  that  needs
> > to be set to 'session' there.
> 
> Ah, that's it.
> 
> > In  one  session  you  will be allowed to lock the
> > same "resource" several times, because it  is  the
> > same session locking it.
> 
> Then  per-transaction locks are the thing me.  Thank
> you.
> 
> -- 
> Anton Shepelev

Well, I might be wrong about this anyway... but what I think
I mean - unless you find different - is that your script can
put two or three or a hundred locks on the same resource,
even exclusive use, because the lock is to reserve the resource
to you, and you can do that with multiple copies of the lock -
or rather, counts of the lock, because lighter and heavier 
locks on the resource add up to the heaviest combination of 
locking - and then it stays locked as heavily as that until
all of the locks are released.

But if you run the script in two windows, one window can
lock the resource, exclusively, and then the other window
can't have it.

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@gmail.com> - 2017-11-25 14:56 +0300
  Re: Using sp_getapplock outside a transaction rja.carnegie@gmail.com - 2017-11-25 05:37 -0800
    Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@gmail.com> - 2017-11-25 18:24 +0300
      Re: Using sp_getapplock outside a transaction rja.carnegie@gmail.com - 2017-11-25 08:36 -0800
        Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@gmail.com> - 2017-11-25 21:13 +0300
          Re: Using sp_getapplock outside a transaction rja.carnegie@gmail.com - 2017-11-25 16:21 -0800
      Re: Using sp_getapplock outside a transaction Erland Sommarskog <esquel@sommarskog.se> - 2017-11-25 21:36 +0100
        Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@gmail.com> - 2017-11-26 19:43 +0300
          Re: Using sp_getapplock outside a transaction Erland Sommarskog <esquel@sommarskog.se> - 2017-11-26 19:55 +0100
            Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@g{oogle}mail.com> - 2017-11-27 11:34 +0300
              Re: Using sp_getapplock outside a transaction Erland Sommarskog <esquel@sommarskog.se> - 2017-11-27 11:56 +0100
                Re: Using sp_getapplock outside a transaction rja.carnegie@gmail.com - 2017-11-27 14:23 -0800
                Re: Using sp_getapplock outside a transaction Erland Sommarskog <esquel@sommarskog.se> - 2017-11-28 08:50 +0100
                Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@g{oogle}mail.com> - 2017-11-29 15:11 +0300
                Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@g{oogle}mail.com> - 2017-11-29 15:22 +0300
                Re: Using sp_getapplock outside a transaction Erland Sommarskog <esquel@sommarskog.se> - 2017-11-29 13:44 +0100
                Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@g{oogle}mail.com> - 2017-11-29 18:44 +0300
                Re: Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@g{oogle}mail.com> - 2017-11-29 19:42 +0300
                Re: Using sp_getapplock outside a transaction rja.carnegie@gmail.com - 2017-11-30 13:19 -0800

csiph-web