September 5, 2006 at 8:15 am
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.
September 5, 2006 at 10:33 am
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.
August 13, 2008 at 12:20 pm
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.
October 8, 2009 at 8:06 am
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
October 9, 2009 at 2:34 am
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
September 29, 2010 at 8:41 pm
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..
November 12, 2012 at 5:11 am
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
November 12, 2012 at 5:21 am
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
November 14, 2012 at 1:14 am
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
September 6, 2014 at 10:21 pm
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
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply