Subject | transaction concurrency question |
---|---|
Author | Eugen Stoianovici |
Post date | 2008-02-29T09:33:03Z |
How does firebird's versioning work on transactions? If i have..let's
say a stocks application. At some point there are 10 items A in stock
Users U1 and U2 both sell 8 A's roughly at the same time:
1. --U1 : begin transaction--
2. --U2 : begin transaction--
3. U1: Insert some sale info into sale table
4. U1: Check if there are 8 A's available (true at this poing)
5. U2: Insert some sale info into sale table
6. U1: Update stock for A to stockA-8 items available
7. U2: Check if there are 8 A'2 available (also true at this point?)
8. --U1: Commit transaction--
9. U2: Update stock for A to stockA-8 items available (which would set
stock for A at -6)
10 --U2: commits--(does firebird accept this transaction?)
From what i understood reading the docs, U2 (the second transaction)
doesn't see what U1 does until U2 commits. Am i right? How does firebird
handle this issue? How should i handle this issue?
Thank You
say a stocks application. At some point there are 10 items A in stock
Users U1 and U2 both sell 8 A's roughly at the same time:
1. --U1 : begin transaction--
2. --U2 : begin transaction--
3. U1: Insert some sale info into sale table
4. U1: Check if there are 8 A's available (true at this poing)
5. U2: Insert some sale info into sale table
6. U1: Update stock for A to stockA-8 items available
7. U2: Check if there are 8 A'2 available (also true at this point?)
8. --U1: Commit transaction--
9. U2: Update stock for A to stockA-8 items available (which would set
stock for A at -6)
10 --U2: commits--(does firebird accept this transaction?)
From what i understood reading the docs, U2 (the second transaction)
doesn't see what U1 does until U2 commits. Am i right? How does firebird
handle this issue? How should i handle this issue?
Thank You