My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
112
attachment: wrost_case.txt
(836 bytes)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Two Concurrent Sessions
Worst case scenario
User1 (Tried to buy 10) User2 (Tried to buy 1) Time Obs.
GET ITEM ... quantity = 10
START TRANSACTION GET ITEM ... quantity = 10 0
UPDATE ... SET quantity = 0 START TRANSACTION 1
COMMIT UPDATE ... SET quantity = -1 2 A trigger is executed, an exception is raised for User2.
ROLLBACK 3
PAYMENT FAYLED USER WARNED THAT THERES NO SUCH ITEM NOT MENSURABLE
START TRANSACTION 5 The payment failed so put the quantity back.
UPDATE ... SET quantity = 10 6
COMMIT 7
Nobody charged erroneously, nobody buyed it. We still have ten items and the User2 could not buy just one.
Powered by
Google Project Hosting