Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Isolation level serializable Expand / Collapse
Posted Thursday, March 4, 2010 1:47 PM


Group: General Forum Members
Last Login: Tuesday, August 16, 2016 2:57 PM
Points: 10, Visits: 36
Can someone explain isolation level serializable?
if two processes run the same stored proc,

Set transaction isolation level serializable
begin tran
declare @currentnum int
Select @currentnum = currentnum from refnumbers where id = 1;
update refnumbers set currentnum =
@currentnum where id = 1;
commit tran

so if user1 and user2 run the select query at the same time, does it mean user2 will not be able to select anything until user1 transaction commits? keep in mind user1 has not ran the update yet, both users are running select.

Can you also explain how serializable level eliminates lost updates?
Post #877144
Posted Thursday, October 27, 2011 5:01 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, May 27, 2016 12:07 AM
Points: 203, Visits: 572
Post #1196826
Posted Thursday, October 27, 2011 5:26 AM


Group: General Forum Members
Last Login: Yesterday @ 7:13 AM
Points: 2,199, Visits: 6,042
If both users will run the select statement at the exact same time, then you’ll have a deadlock. When you work with serializable isolation level, the shared locks that were acquired by both processes will be held until the end of the transactions. Since both processes will next try to update the table, each one of them will have to wait for the other process to release the shared lock. This will cause a deadlock and one of the transactions will be rolled back.


To know how to ask questions and increase the chances of getting asnwers:

For better answers on performance questions, click on the following...
Post #1196830
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse