Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


What is extended proc sp_releaseschemalock


What is extended proc sp_releaseschemalock

Author
Message
71 camaro
71 camaro
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 Visits: 112

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.


Shawn Wilson
Shawn Wilson
SSC-Enthusiastic
SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)

Group: General Forum Members
Points: 197 Visits: 286

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.





Andrew..Peterson
Andrew..Peterson
Old Hand
Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)Old Hand (342 reputation)

Group: General Forum Members
Points: 342 Visits: 682
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.
balde
balde
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 597
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



balde
balde
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 597
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



andyansryan
andyansryan
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 49
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..
Mrinalini10
Mrinalini10
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 81
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
balde
balde
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 597
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



Mrinalini10
Mrinalini10
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 81
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
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45068 Visits: 39904
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search