473,799 Members | 3,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how long a table blocked

I have written a stored procedure to list out all tables in which
rows or the table itself is locked. The only information I am
not able to get is the time when the lock occurred. The way I
want is that if I run the procedure it should show all locks
on a table which are at least 5 or x seconds old. This way I can
avoid momentary locks on a table which go away after few seconds.

Which table and column of master database has that information?

Thanks.

--

email id is bogus
Jul 20 '05 #1
3 2744
rkusenet (rk******@sympa tico.ca) writes:
I have written a stored procedure to list out all tables in which
rows or the table itself is locked. The only information I am
not able to get is the time when the lock occurred. The way I
want is that if I run the procedure it should show all locks
on a table which are at least 5 or x seconds old. This way I can
avoid momentary locks on a table which go away after few seconds.

Which table and column of master database has that information?


I'm afraid that this information is not available. There is a
req_lifetime column in syslockinfo, which is carefully document,
but the essence of the documentation is that this is an internal
column.
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
To my knowledge that info is not available. And maybe not so interesting (my
opinion) Technicaly what is interesting about locked table is the fact that
others have to wait because they want access to the table (or rows or keys
or whatever) in an incompatible mode.
The nice thing about this is that the time information about that fact is
available, but maybe hard to get through a stored proc. But a good sp
programmer should be able figure that out ;-)
The wait information is in sysprocesses, if the 'lastwaittype' is of type
'LCK..' a spid is waiting for a lock (if waittime > 0) (or 'waittype between
0x01 and 0x1f). 'Waitresource' will show what is being waited for TBL/KEY
etc. and waittime how long the spid is waiting now.

I hope that brings you closer to what you want..

--
regards,
Mario

http://www.sqlinternals.com

"rkusenet" <rk******@sympa tico.ca> wrote in message
news:bn******** ****@ID-75254.news.uni-berlin.de...
I have written a stored procedure to list out all tables in which
rows or the table itself is locked. The only information I am
not able to get is the time when the lock occurred. The way I
want is that if I run the procedure it should show all locks
on a table which are at least 5 or x seconds old. This way I can
avoid momentary locks on a table which go away after few seconds.

Which table and column of master database has that information?

Thanks.

--

email id is bogus

Jul 20 '05 #3

"Mario" <no****@sqlinte rnals.com> wrote in message news:3f******** *************** @news.xs4all.nl ...
To my knowledge that info is not available. And maybe not so interesting (my
opinion) Technicaly what is interesting about locked table is the fact that
others have to wait because they want access to the table (or rows or keys
or whatever) in an incompatible mode.
The nice thing about this is that the time information about that fact is
available, but maybe hard to get through a stored proc. But a good sp
programmer should be able figure that out ;-)
The wait information is in sysprocesses, if the 'lastwaittype' is of type
'LCK..' a spid is waiting for a lock (if waittime > 0) (or 'waittype between
0x01 and 0x1f). 'Waitresource' will show what is being waited for TBL/KEY
etc. and waittime how long the spid is waiting now.

I hope that brings you closer to what you want..

thanks Mario and Erland. With your help I am able to develop the stored procedure
we require.

--

email id is bogus
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2170
by: LineVoltageHalogen | last post by:
Greetings All, I was wondering what would happen if I were to do a "select * from table" on a table that has about 5 million rows. Would my read block other writers to the same table? Would it block other readers? I know SQL uses optimistic lockign by default but I am not sure what this means to other users trying to access the same table? Any advise would be greatly appreciated. TFD
6
10580
by: ujjc001 | last post by:
Hello all. I have many connections that are sleeping. I can right click, kill, up to 2 at a time. It takes about 20 seconds to kill it. Is that normal? I tried to make a stored procedure to kill them but it ate all the power of the server, (all users yelled at me at the same time :o) ) Is this length of time normal for killing these processes? Thanks Jeff
29
5822
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using the transaction because I need a way to roll it back if any errors happen during the transaction. Unfortunately all tables affected in the long running transaction are completely locked and nobody else can access any of the affected tables while...
17
3853
by: laurenq uantrell | last post by:
In master.dbo.sysprocesses I can filter for blocked users (Blocked >0) and I can create a self join(ON SPID = Blocked) to see what user Loginame is causing the block. In the column I can see the command that the offending blocker is running to cause the block, but it only says "SELECT" etc. with no details about the stored procedure that is causing the block. If I am running a Trace, I can see the exact stored procedures including the...
5
8723
by: Eric Freeman | last post by:
I'm trying to drop a table and it's taking a very long time. There has been a lot of modification to the table and it has a lot of old data still being used as a result of not using the vacuum function enough. I ran an insert into and it was taking a long time (ran for about 48 hours) so I aborted it. I tried vacuuming it and that ran for about the same amount of time before I aborted. I figured the fastest ting would be to drop the table...
4
4942
by: Dr. J | last post by:
How to terminate a blocked thread? In my form's "load" I launch a TCP listening thread that stays in an infinite loop waiting for incoming TCP packets. In this form's "closing" I try to terminate this thread by calling the "Abort" funcion. But the thread does not terminate and after the form is closed this thread keeps running at blocked state. Basically the application keeps running because this thread does not terminate while...
1
5763
by: cheesey_toastie | last post by:
I have a long query which I have set off and would like to stop, and rename one of the tables used. My query is due to my lack of understanding of the underlying structure of MSSQL-Server... So say and update updates TABLE_A and I stop it, whilst this transaction is rolling back I attempt to rename TABLE_A to TABLE_A_OLD and rename a different table to become TABLE_A. I am assuming that the rollback actions will use the object...
2
2142
by: Ryan Liu | last post by:
Hi, I have few db write and read to execute, so I use transaction. Is that a problem or is that a regular way that I only use transaction on some cmds only, and other cmds I do not use trasaction, esp those read actions, or even use another dbconnection to read? BTW, what does "open table" menas? Is that table only be "open" when someone read or write it. Once all user finish read or write the db table, the
32
1712
by: John Wright | last post by:
I have a long process I run that needs to be complete before the user can continue. I can change the cursor to an hourglass, but I want to update the Status Strip on the bottom during the process. I set the statusstrip label to "Downloading...", but it will not show up on the form. I need to display this message before it starts the process. I can put a thread.sleep for 1 second after I do the initial process, but that seems sloppy to me. ...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.