Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dlouche
Starting Member
9 Posts |
Posted - 2009-02-02 : 10:57:31
|
| I’m working on an auction like website where in the database I am storing user bids Bids ---------------------------------- int ID int UserID decimal BidAmountThe bid amount is to be determined automatically based on the previous bid amount (i.e. each bid equals the previous bid plus a specific amount). When a user bids, I want to query the table to determine the current highest bid amount, and then use that data to insert a new bid. However I am concerned about a race condition between the query for the highest bid and the insert of the new bid (e.g. user A queries to determine the highest bid is $10, user B inserts a high bid of $10.50, then user A inserts a bid of $10.50, when it should have been $11). So I want to block a ‘bidding’ user from querying the table (but non-bidding users should not be blocked) until any active bids are complete. My guess at how to accomplish this would be to use a mutex (I’ve only been able to find one decent article on this) in the bid operation, but I wanted to get your guys opinion (and references/examples?).Thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
dlouche
Starting Member
9 Posts |
Posted - 2009-02-02 : 11:10:12
|
| That's the article I was referring to!I can solve it in the app with a mutex, but I thought a db solution might be more efficient. But that's not based on anything but hope. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2009-02-02 : 11:14:00
|
| i would suggest you solve it in the app then.___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
|
|
|