Subscribe to
Posts
Comments

One of the SQL Server that I manage has a couple non-updatable transactional publications defined in a database. I needed to push those publications to a new subscribing SQL Server. Usually the process is relative simple.

I usually right click on the publication in Enterprise Manager, select push new subscription, select a database server (you will have to enable it as a subscriber prior to that), select a database, define a schedule, choose a subscriber initialization option and then click “Finish”. After that SQL server will create the subscription for you and create the snapshot job and distribution job on the distributing server (if you choose to run those jobs on distributor which was typical).

However when I clicked on the “Finish” button today SQL Server just hung at the step to create subscription and never finish the task of setting up replication. The following screen shot shows where the step SQL Server was hanging at.
SQL Server Hang at Creating Subscription

When setting up replication Enterprise Manager was running some store procedures on the database behind the scene. Most likely SQL Server was hanging on that step because the store procedure it was executing was waiting to acquire locks on the tables being published. That means some other process was locking the tables being published.

In order to find which process lock up a table I usually go to Enterprise Manager, right click on “Current Activit” under Management, click refresh and then expand “Locks/Object”. You will see which table was locked by which process there. However when I try to do that I got the message “Error 1222: Lock Request Time Out Period Exceeded”

Error 1222 Lock Request Time Out Period Exceeded

How to deal with that? Keep waiting is not a solution. Fortunately to see what process lock up which table you don’t have to use Enterprise Manager. The following query will do that.

select distinct object_name(a.rsc_objid), a.req_spid, b.loginame
from master.dbo.syslockinfo a (nolock) join
master.dbo.sysprocesses b (nolock) on a.req_spid=b.spid
where object_name(a.rsc_objid) is not null

The query will show which table was locked, the process that lock the table and the login name used by the process. Once you find out which process lock the tables you can issue a “kill @spid” statement to kill those processes (make sure if it is save to do that first). Don’t kill the process trying to create the subscription though. Once the other process is killed Enterprise Manager will be able to finish its job to cerate the subscription.

If you experience this problem then most likely you will experience the same thing when the snapshot job of the publication runs in order to initialize subscriber. In that case the same trick can solve the problem. Use the query to find out which process lock up the tables being published and kill them. But again it will be up to you to fine out whether it is save to kill those process that hang your replication set up.


Related Posts:

  • Error Reading Packet From Server Error Reading Log Entry Server_Errno=1236
  • MySQL Replication and MS SQL Log Shipping
  • How to Script Out all The Foreign Keys of a Table
  • How to Kill AutoShrink Process
  • Trouble Shooting SQL Server Connection Problems, Tricks and Solutions


  • 1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4 out of 5)
    Loading ... Loading ...

    RSS feed | Trackback URI

    8 Comments »

    Comment by gomeEndavedge
    2008-12-29 07:09:56
    MyAvatars 0.2

    jabugnunummdxunawell, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch ;)

     
    Comment by Chris Subscribed to comments via email
    2009-01-27 10:36:34
    MyAvatars 0.2

    Thank you! This post is a life-saver! MS’s own incompetant help page doesn’t even tell you how to fix this (http://msdn.microsoft.com/en-us/library/aa337412.aspx).

     
    Comment by cesa
    2010-01-26 07:29:13
    MyAvatars 0.2

    :)) thank you. it works…

     
    Comment by Rakhi
    2010-05-19 23:40:47
    MyAvatars 0.2

    good dude.. keep rocking… thanks a lot :smile:

     
    Comment by Sreekanth
    2010-06-23 21:10:24
    MyAvatars 0.2

    Hi this is really helped me. Thanks for sharing.

     
    Comment by Kevin Languedoc
    2010-09-29 11:51:46
    MyAvatars 0.2

    Great tip

     
    Comment by RAGHU
    2011-03-15 12:36:44
    MyAvatars 0.2

    Thanks dude,it is really help me.

     
    2011-06-08 09:43:46
    MyAvatars 0.2

    […] my Alter Table command from running.  For that I used a query I found on this blog post Error 1222 Lock Request Time Out Period Exceeded When Set up Replication by Andrew […]

     
    Name (required)
    E-mail (required - never shown publicly)
    URI
    Subscribe to comments via email
    Your Comment (smaller size | larger size)
    You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.