但要如何解决,我就不会了,根本找不出来是那里被阻塞了
请帮忙
8 个解决方案
#1
又,我看了一下sp_who中的blk全都为0,按帮助上的说法
应该是没有阻塞才对呀?
疑惑ing
应该是没有阻塞才对呀?
疑惑ing
#2
USE master
EXEC sp_lock
EXEC sp_lock
#3
谢谢mjhnet
我用很笨的方法,一段一段的执行代码
最后发现试这一段代码执行时会出现 "已超过了锁请求超时时段" BEGIN TRANSACTION
ALTER TABLE Company
ADD CONSTRAINT DEF_Company_name
DEFAULT '某家公司'FOR name
GO
然后我执行sp_lock
sp_lock执行后是这样的。我看不大懂,谁帮我看看,是什么地方的问题?
Spid dbid ObjId IndId Type Resource Mode Status
53 11 6 0 TAB IX GRANT
53 11 0 0 DB S GRANT
53 11 1 0 TAB IX GRANT
53 11 3 0 TAB IX GRANT
53 11 1 2 KEY (f00221a84eba) X GRANT
53 11 6 1 KEY (2800ff48955f) X GRANT
53 11 9.82E+08 0 TAB Sch-M GRANT
53 11 1.98E+09 0 TAB Sch-M GRANT
53 11 1 3 KEY (46002017d8a6) X GRANT
53 11 1 1 KEY (27009587d2c0) X GRANT
53 11 3 1 KEY (2100dd78b812) X GRANT
53 11 1 1 KEY (1f009814a4db) X GRANT
54 1 85575343 0 TAB IS GRANT
54 11 0 0 DB S GRANT
我用很笨的方法,一段一段的执行代码
最后发现试这一段代码执行时会出现 "已超过了锁请求超时时段" BEGIN TRANSACTION
ALTER TABLE Company
ADD CONSTRAINT DEF_Company_name
DEFAULT '某家公司'FOR name
GO
然后我执行sp_lock
sp_lock执行后是这样的。我看不大懂,谁帮我看看,是什么地方的问题?
Spid dbid ObjId IndId Type Resource Mode Status
53 11 6 0 TAB IX GRANT
53 11 0 0 DB S GRANT
53 11 1 0 TAB IX GRANT
53 11 3 0 TAB IX GRANT
53 11 1 2 KEY (f00221a84eba) X GRANT
53 11 6 1 KEY (2800ff48955f) X GRANT
53 11 9.82E+08 0 TAB Sch-M GRANT
53 11 1.98E+09 0 TAB Sch-M GRANT
53 11 1 3 KEY (46002017d8a6) X GRANT
53 11 1 1 KEY (27009587d2c0) X GRANT
53 11 3 1 KEY (2100dd78b812) X GRANT
53 11 1 1 KEY (1f009814a4db) X GRANT
54 1 85575343 0 TAB IS GRANT
54 11 0 0 DB S GRANT
#4
你运行下面的sp,将结果贴出来
http://expert.csdn.net/Expert/topic/1512/1512038.xml?temp=.1046106
http://expert.csdn.net/Expert/topic/1512/1512038.xml?temp=.1046106
#5
在添加默认约束的DEF_Company_name之前执行sp_lock2,结果如下:51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
添加默认约束后,再次执行sp_lock2,没有结果产生,无法停止。
死了
???
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
添加默认约束后,再次执行sp_lock2,没有结果产生,无法停止。
死了
???
#6
上一贴乱了,再贴
51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
#7
这是我以前用来取消阻塞用的,在这里可以查到哪个进程阻塞了!
你可以自己制造阻塞然后测试,
drop procedure sp_killblockingprocess
go
--杀除发起阻塞的进程
--用法:sp_killblockingprocess waittime 其中waittime单位是毫秒,为已经阻塞的时间
--如:杀除发起阻塞已经有40秒的进程 exec sp_killblockingprocess
--注意:必须将该过程放在master库中
CREATE PROCEDURE sp_killblockingprocess
@waittime int =20000
as
DECLARE @spid smallint,@waitt int,@killp varchar(20)
declare cblocked CURSOR FOR
select spid,waittime from sysprocesses where blocked=0 and open_tran>0 and waittime>@waittime
and spid in (select blocked from sysprocesses where blocked >0 )
open cblocked
FETCH NEXT FROM cblocked into @spid,@waitt
WHILE @@FETCH_STATUS = 0
BEGIN
--kill @spid
select @killp="KILL "+convert(char(10),@spid)
print @killp
exec sp_sqlexec @killp
FETCH NEXT FROM cblocked into @spid,@waitt
end
CLOSE cblocked
DEALLOCATE cblocked
你可以自己制造阻塞然后测试,
drop procedure sp_killblockingprocess
go
--杀除发起阻塞的进程
--用法:sp_killblockingprocess waittime 其中waittime单位是毫秒,为已经阻塞的时间
--如:杀除发起阻塞已经有40秒的进程 exec sp_killblockingprocess
--注意:必须将该过程放在master库中
CREATE PROCEDURE sp_killblockingprocess
@waittime int =20000
as
DECLARE @spid smallint,@waitt int,@killp varchar(20)
declare cblocked CURSOR FOR
select spid,waittime from sysprocesses where blocked=0 and open_tran>0 and waittime>@waittime
and spid in (select blocked from sysprocesses where blocked >0 )
open cblocked
FETCH NEXT FROM cblocked into @spid,@waitt
WHILE @@FETCH_STATUS = 0
BEGIN
--kill @spid
select @killp="KILL "+convert(char(10),@spid)
print @killp
exec sp_sqlexec @killp
FETCH NEXT FROM cblocked into @spid,@waitt
end
CLOSE cblocked
DEALLOCATE cblocked
#8
奇怪的事情发生了
我在关上已经锁住的程序界面时,跳出下列提示:
有未提交的事务
是否希望再关闭窗口前提交这些事务?
然后我就yes了
默认约束居然就加上了,后来又试了很多次,
再也没出现过 “锁请求超时”
这是怎么回事?
虽然问题解决了,可我还是不明白
我在关上已经锁住的程序界面时,跳出下列提示:
有未提交的事务
是否希望再关闭窗口前提交这些事务?
然后我就yes了
默认约束居然就加上了,后来又试了很多次,
再也没出现过 “锁请求超时”
这是怎么回事?
虽然问题解决了,可我还是不明白
#1
又,我看了一下sp_who中的blk全都为0,按帮助上的说法
应该是没有阻塞才对呀?
疑惑ing
应该是没有阻塞才对呀?
疑惑ing
#2
USE master
EXEC sp_lock
EXEC sp_lock
#3
谢谢mjhnet
我用很笨的方法,一段一段的执行代码
最后发现试这一段代码执行时会出现 "已超过了锁请求超时时段" BEGIN TRANSACTION
ALTER TABLE Company
ADD CONSTRAINT DEF_Company_name
DEFAULT '某家公司'FOR name
GO
然后我执行sp_lock
sp_lock执行后是这样的。我看不大懂,谁帮我看看,是什么地方的问题?
Spid dbid ObjId IndId Type Resource Mode Status
53 11 6 0 TAB IX GRANT
53 11 0 0 DB S GRANT
53 11 1 0 TAB IX GRANT
53 11 3 0 TAB IX GRANT
53 11 1 2 KEY (f00221a84eba) X GRANT
53 11 6 1 KEY (2800ff48955f) X GRANT
53 11 9.82E+08 0 TAB Sch-M GRANT
53 11 1.98E+09 0 TAB Sch-M GRANT
53 11 1 3 KEY (46002017d8a6) X GRANT
53 11 1 1 KEY (27009587d2c0) X GRANT
53 11 3 1 KEY (2100dd78b812) X GRANT
53 11 1 1 KEY (1f009814a4db) X GRANT
54 1 85575343 0 TAB IS GRANT
54 11 0 0 DB S GRANT
我用很笨的方法,一段一段的执行代码
最后发现试这一段代码执行时会出现 "已超过了锁请求超时时段" BEGIN TRANSACTION
ALTER TABLE Company
ADD CONSTRAINT DEF_Company_name
DEFAULT '某家公司'FOR name
GO
然后我执行sp_lock
sp_lock执行后是这样的。我看不大懂,谁帮我看看,是什么地方的问题?
Spid dbid ObjId IndId Type Resource Mode Status
53 11 6 0 TAB IX GRANT
53 11 0 0 DB S GRANT
53 11 1 0 TAB IX GRANT
53 11 3 0 TAB IX GRANT
53 11 1 2 KEY (f00221a84eba) X GRANT
53 11 6 1 KEY (2800ff48955f) X GRANT
53 11 9.82E+08 0 TAB Sch-M GRANT
53 11 1.98E+09 0 TAB Sch-M GRANT
53 11 1 3 KEY (46002017d8a6) X GRANT
53 11 1 1 KEY (27009587d2c0) X GRANT
53 11 3 1 KEY (2100dd78b812) X GRANT
53 11 1 1 KEY (1f009814a4db) X GRANT
54 1 85575343 0 TAB IS GRANT
54 11 0 0 DB S GRANT
#4
你运行下面的sp,将结果贴出来
http://expert.csdn.net/Expert/topic/1512/1512038.xml?temp=.1046106
http://expert.csdn.net/Expert/topic/1512/1512038.xml?temp=.1046106
#5
在添加默认约束的DEF_Company_name之前执行sp_lock2,结果如下:51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
添加默认约束后,再次执行sp_lock2,没有结果产生,无法停止。
死了
???
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
添加默认约束后,再次执行sp_lock2,没有结果产生,无法停止。
死了
???
#6
上一贴乱了,再贴
51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
51 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
52 NT AUTHORITY\SYSTEM TAII 4 msdb 0 0 DB S GRANT
54 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 11 followme10 0 0 DB S GRANT
55 TAII\Administrator TAII 2 tempdb 782625831 #locktable__________________________________________________________________________________________________________00010000001A 0 TAB IX GRANT
55 TAII\Administrator TAII 1 master 85575343 spt_values 0 TAB IS GRANT
#7
这是我以前用来取消阻塞用的,在这里可以查到哪个进程阻塞了!
你可以自己制造阻塞然后测试,
drop procedure sp_killblockingprocess
go
--杀除发起阻塞的进程
--用法:sp_killblockingprocess waittime 其中waittime单位是毫秒,为已经阻塞的时间
--如:杀除发起阻塞已经有40秒的进程 exec sp_killblockingprocess
--注意:必须将该过程放在master库中
CREATE PROCEDURE sp_killblockingprocess
@waittime int =20000
as
DECLARE @spid smallint,@waitt int,@killp varchar(20)
declare cblocked CURSOR FOR
select spid,waittime from sysprocesses where blocked=0 and open_tran>0 and waittime>@waittime
and spid in (select blocked from sysprocesses where blocked >0 )
open cblocked
FETCH NEXT FROM cblocked into @spid,@waitt
WHILE @@FETCH_STATUS = 0
BEGIN
--kill @spid
select @killp="KILL "+convert(char(10),@spid)
print @killp
exec sp_sqlexec @killp
FETCH NEXT FROM cblocked into @spid,@waitt
end
CLOSE cblocked
DEALLOCATE cblocked
你可以自己制造阻塞然后测试,
drop procedure sp_killblockingprocess
go
--杀除发起阻塞的进程
--用法:sp_killblockingprocess waittime 其中waittime单位是毫秒,为已经阻塞的时间
--如:杀除发起阻塞已经有40秒的进程 exec sp_killblockingprocess
--注意:必须将该过程放在master库中
CREATE PROCEDURE sp_killblockingprocess
@waittime int =20000
as
DECLARE @spid smallint,@waitt int,@killp varchar(20)
declare cblocked CURSOR FOR
select spid,waittime from sysprocesses where blocked=0 and open_tran>0 and waittime>@waittime
and spid in (select blocked from sysprocesses where blocked >0 )
open cblocked
FETCH NEXT FROM cblocked into @spid,@waitt
WHILE @@FETCH_STATUS = 0
BEGIN
--kill @spid
select @killp="KILL "+convert(char(10),@spid)
print @killp
exec sp_sqlexec @killp
FETCH NEXT FROM cblocked into @spid,@waitt
end
CLOSE cblocked
DEALLOCATE cblocked
#8
奇怪的事情发生了
我在关上已经锁住的程序界面时,跳出下列提示:
有未提交的事务
是否希望再关闭窗口前提交这些事务?
然后我就yes了
默认约束居然就加上了,后来又试了很多次,
再也没出现过 “锁请求超时”
这是怎么回事?
虽然问题解决了,可我还是不明白
我在关上已经锁住的程序界面时,跳出下列提示:
有未提交的事务
是否希望再关闭窗口前提交这些事务?
然后我就yes了
默认约束居然就加上了,后来又试了很多次,
再也没出现过 “锁请求超时”
这是怎么回事?
虽然问题解决了,可我还是不明白