Şöyle yaparız
-- Transaction ABEGIN;UPDATE Orders SET Quantity = Quantity - 1 WHERE OrderID = 1;-- Now Transaction A needs to update CustomersUPDATE Customers SET TotalOrders = TotalOrders + 1 WHERE CustomerID = 1;COMMIT;-- Transaction BBEGIN;UPDATE Customers SET TotalOrders = TotalOrders - 1 WHERE CustomerID = 1;-- Now Transaction B needs to update OrdersUPDATE Orders SET Quantity = Quantity + 1 WHERE OrderID = 1;COMMIT;
Açıklaması şöyle
In this example, if Transaction A and Transaction B are executed concurrently and the timing is such that Transaction A locks the Orders table and Transaction B locks the Customers table before either has a chance to commit, a deadlock will occur.
No comments:
Post a Comment