Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSgetmakegenerationapplock

  No additional text.


Syntax

create procedure sys.sp_MSgetmakegenerationapplock
    @head_of_queue int OUTPUT
    as
    set nocount on

    declare @retcode smallint
    declare @lock_resource nvarchar(255)
    declare @DbPrincipal sysname

    -- Security check
    exec @retcode = sys.sp_MSrepl_PAL_rolecheck
    if (@retcode <> 0) or (@@error <> 0)
            return 1

      select @retcode = 0
    select @head_of_queue = 0

    select @lock_resource = N'MSinternal_makegeneration_inprogress' +
                convert(nvarchar(11), db_id())
    if exists (select * from sys.database_principals where name=N'MSmerge_PAL_role' and type = 'R')
        select @DbPrincipal = N'MSmerge_PAL_role'
    else
        select @DbPrincipal = N'db_owner'

    -- If someone else is making generations / has just made one, exit so
    -- that we won't deadlock
    exec @retcode = sp_getapplock @Resource = @lock_resource,
                                  @LockMode = N'Exclusive',
                                  @LockOwner = N'Session',
                                  @LockTimeout = 0, -- do not wait at all.
                                  @DbPrincipal = @DbPrincipal

    if @@error <> 0 or @retcode < 0
    begin
        -- If the previous applock request timed out, then try again, this time using the default timeout.
        -- Note that even though the -1 lock timeout means indefinite timeout, the query timeout set on the
        -- session overrides the lock timeout. So it's okay even if the default @@lock_timeout is -1.
        if (@retcode = -1)
        begin
            exec @retcode = sp_getapplock @Resource = @lock_resource,
                        @LockMode = N'Exclusive',
                        @LockOwner = N'Session',
                        @DbPrincipal = @DbPrincipal

            -- If we succeeded to get the lock, set @lock_acquired to 1 so that the exit code releases the lock.
            if (@retcode >= 0)
            begin
                goto EXIT_PROC
            end
        end
    end
    else
    begin
        select @head_of_queue = 1
    end

EXIT_PROC:
    return @retcode


 
Last revision 2008RTM
See also

  sp_MScreatedummygeneration (Procedure)
sp_MSdrop_rlcore (Procedure)
sp_MSgetmakegenerationapplock_90 (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash