What is extended proc sp_releaseschemalock

  • Does anyone have documentation or know what sp_releaseschemalock does?

    I had an issue that occurred last week when I was on vaca. The above proc was blocking for over 24 hours being called thru linked server.  All my logs are gone so I do not know who or what. All I have is he was the head of the chain..

    The application experienced issues during this window and my boss wanted me to se if I saw anything.

    The blocking continued until sql was restarted. 

    It is sql2000 sp4.

     

  • I've seen this happen where there was a linked server query running and killed.  However the connection persisted and was reporting it was at a 100 percent in the rollback state, but was blocking other queries.  I simply stopped / started DTC on the linked server and then the connection cleared.  In my several cases, this has always worked for me without having to stop/start sqlserver.

     

    You should check your linked server configurations and make sure they are "collation compatible" checked. Otherwise the entire remote table is returned to the local calling server to execute the WHERE clause.

    In regards to sp_releaseschemalock ....below is part of a rootcause analysis I had to give one time before.  I've edited it quite a bit to rip out tablenames/queries we use.  I used profiler to capture these sprocs.

     

    This is one of many sp's which are called as a result of a linkedserver query.

     

    sp_tables_info_rowset tblXXX

    sp_columns_rowset tblXXX

    sp_indexes_rowset tblXXX

    sp_check_constbytable_rowset tblXXX

    sp_provider_types_rowset tblXXX

    sp_table_statistics_rowset tblXXX

    sp_getschemalock tblXXX

    exec sp_prepexec @P1 output, NULL, N'SELECT "Col1601" FROM (SELECT "some dynamic generated query" FROM "dbname"."dbo"."tblName" WHERE somecriteria)

    sp_releaseschemalock tblXXX

    sp_releaseschemalock tblXXX

    sp_releaseschemalock tblXXX

     

    All of this overhead generates a lot of disk IO's and stacks up on the blocking.

    All of this occurs because the SQL Server on serverA has no statistical information about the tables involved in the linked query.  ServerB will always inquire that information for each call.

     

     

    Hope this helps out some.

  • Yea, there is not much out there on sp_getschemalock or sp_releaseschemalock.

    I did find some reference to the locks on the schema (BOL) locks sch-m, sch-s if you do a search.

    The more you are prepared, the less you need it.

  • Hi all,

    I have a stored-procedure running on an SQL2k5 box which is updating a table on a SQL2k linked server.

    I have ensured that the "Collation Comaptible" optiions are set True at both ends of the link, but still my query seems to perform a full table scan (some 2million+ rows) for a single update.

    The where clause is matching a single value of the primary key ( an integer identity column) and updating a single row in the table.

    collation of the remote DB (on the sql2k box) is SQL_Latin1_General_CP1_CI_AS

    collation of the local DB (where the Sp runs from ) is SQL_Latin1_General_CP1_CI_AS

    can anyone suggest how to prevent the full table scan? this is taking anything from 45 minutes to 1.5 hours to run,

    many thanks in advance

  • Well, i didn't work out how to stop the full table scan when performing updates across linked-servers, but there is a better way of achieving the required result (as always!).

    rather than have an update statement on the remote server, i have added a stored procedure to the linked server which i simply pass the required primary key value to; the Sp on linked server then performs the update.

    so use;

    exec linkedserver.db.dbo.sp @pk_id

    rather than;

    update linkedserver.db.dbo.table set a = b were pk_id = @pk_id

    Result is no schema lock required and the process is now running in a few seconds rather than 45 minutes.

    hope this helps other folk with the same performance hit when using linked servers.

    ....I would still ike to know if it's possible to prevent the full table scan on linked server table updates, so if anyone can contribute to the thread along these lines please do so!

    cheers

  • I had the same issue. It had to do with a schema changed being applied via linked server. I killed the spid and the blocking was gone..

  • I am having similar issue on SQL 2008 where there is a view created on Server A which retrieves data from 3 tables ( 1,2,3) residing on Server B through linked server . There is blocking that happens when there is process that tries to UPDATE table 3 .

    It waits on lock for one of the table 'Table 1' which takes part in the view defintion.

    This is been blocked by a SPID which is executing [sys.sp_releaseschemalock] called by from 'Microsoft SQL Server '

    I already tried the option 'collation compatible' true but it dint help.

    Any help would be appreciated

  • Are you able to set-up replication of the 3 tables from server B to server A; the view on A will then be much more efficient and replication is very simple to set-up?

    cheers

  • We dont want to setup replication.. we would like to use the current setup.

    When both database are on same SQL instance ( that is when the view is created without calling linked server ) we dont face this issue

  • Shawn Wilson (9/5/2006)


    I've seen this happen where there was a linked server query running and killed. However the connection persisted and was reporting it was at a 100 percent in the rollback state, but was blocking other queries. I simply stopped / started DTC on the linked server and then the connection cleared. In my several cases, this has always worked for me without having to stop/start sqlserver.<FONT size=2>

    You should check your linked server configurations and make sure they are "collation compatible" checked. Otherwise the entire remote table is returned to the local calling server to execute the WHERE clause.</FONT>

    In regards to sp_releaseschemalock ....below is part of a rootcause analysis I had to give one time before. I've edited it quite a bit to rip out tablenames/queries we use. I used profiler to capture these sprocs.

    This is one of many sp's which are called as a result of a linkedserver query.

    <FONT face="times new roman" size=3>sp_tables_info_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_columns_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_indexes_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_check_constbytable_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_provider_types_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_table_statistics_rowset tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_getschemalock tblXXX</FONT><FONT face="times new roman" size=3></FONT>

    <FONT face="times new roman" size=3>exec sp_prepexec @P1 output, NULL, N'SELECT "Col1601" FROM (SELECT "some dynamic generated query" </FONT><FONT face="times new roman" size=3>FROM "dbname"."dbo"."tblName"WHERE somecriteria)</FONT>

    <FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

    <FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

    <FONT face="times new roman" size=3></FONT>

    <FONT face="times new roman" size=3>All of this overhead generates a lot of disk IO's and stacks up on the blocking.</FONT>

    <FONT face="times new roman" size=3>All of this occurs because the SQL Server onserverA has no statistical information about thetablesinvolved in the linked query. ServerBwill always inquire that information for each call.</FONT>

    <FONT face="times new roman" size=3></FONT>

    <FONT face="Times New Roman" size=3></FONT>

    <FONT face="Times New Roman" size=3>Hope this helps out some.</FONT>

    I know this is an 8 year old post but I wanted to say thanks... this is good stuff and just exactly what I was looking for.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 1 through 9 (of 9 total)

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