Re: Simple locking question.....
From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 02/22/05
- Next message: R Reyes: "Re: table data link - "add extra field" vs "new table with a key""
- Previous message: G Dean Blake: "Re: using SET in VB code"
- In reply to: len: "Simple locking question....."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 12:23:25 -0600
Yes, any time you are modifying any resource, and viewing any resource
(unless you are in READ UNCOMMITTED isolation) you will have locks being
held for some duration (depending on which isolation level the length of
locks on viewing is variable.)
Usually, other processes simply wait until any other processes release the
locks that they were using before starting their own locks. So say process
1 locks resource X, if process 2 needs resource X, it will wait until
process 1 is finished.
Deadlocks come when two processes are blocking each other. So if in the
previous example, process 2 already had resource Y locked, and process 1 has
resource X locked, a deadlock would occur if process 2 needed X and process
1 needed Y. They are waiting on each other, so the would never complete
unless the other completed. Hence, one process has to be terminated (this
is called the victim)
Usually deadlocks are no problem whatsoever, you just redo your action you
wanted to do with the victim. As long as they are rare, I wouldn't worry
too much about it.
-- ---------------------------------------------------------------------------- Louis Davidson - drsql@hotmail.com SQL Server MVP Compass Technology Management - www.compass.net Pro SQL Server 2000 Database Design - http://www.apress.com/book/bookDisplay.html?bID=266 Blog - http://spaces.msn.com/members/drsql/ Note: Please reply to the newsgroups only unless you are interested in consulting services. All other replies may be ignored :) "len" <len@discussions.microsoft.com> wrote in message news:10EC7E29-B955-4766-8B77-1041C2A49DEB@microsoft.com... > Here's a simlple enough question: > > If somebody is deleting from a table in SQL (with a simple DELETE FROM... > TSQL query), will there be a lock on this table such that another process > can't > - UPDATE that table > - DELETE from that table > - SELECT from that table (not sure about this one) ? > > I just got a rare "Transaction (Process ID 57) was deadlocked... chosen as > deadlock victim" error msg from a process of mine and I just want to > establish what the pther process may have been doing at the time. > > what I think happened was process X was deleting from the table and > process > 57 tried an update. > > Q: Is is ok to run SELECT statements, if another process is deleting or > inserting from a table? > >
- Next message: R Reyes: "Re: table data link - "add extra field" vs "new table with a key""
- Previous message: G Dean Blake: "Re: using SET in VB code"
- In reply to: len: "Simple locking question....."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|