Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

[web] Problems with concurrent users in web apps

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am working on a web app for a company... it uses ASP.NET and VB.NET. Anyway, we do a lot of transaction processing via flat files and FTP (ugh)... for example the user might want to fill out a form to pay bills to the wholesalers... so for this I have a nice little datagrid which displays any pending bills that it grabs off our database, and I have checkboxes in the row of the DG, so they can select what bills they want to pay and then click a "pay checked bills" button and it grabs the data for the ones they have checked off from the DB, creates a flat file w/ that data, then FTP's it and marks that row's has_been_processed field to true. the "view pending bills" only displays bills where has_been_processed is false. ok, now here's the problem... what happens when Joe Blow wants to pay some bills... he goes to the "view pending bills" page... hes a little slow and looks at the screen for 5 minutes untill he finds the bill he wants to pay, checks it off, then clicks the "pay checked bills" button... Now, what happens if during that 5 minutes Joe was taking to find the bill, Bob down the hall goes to the "view pending bills" page, sees that same bill, and clicks "pay bill".. Joe's screen will still show it as a pending bill since his page loaded when it WAS still pending, and Joe will then click "pay checked bills" and that bill will get paid twice... The best solution I have come up to this feels like a total hack. Basically, when the user clicks "pay checked bills", the first thing I do is loop through all checked rows and check if has_been_processed is set to true... if it is, I then remove this row from our list, if it is not true, we then set it to true... when then process and pay any bills left in our list. this is the best idea I can come up with but it just feels dirty and I don't think it will hold up with concurrent users.. I think I might have to do table locking or something but I'm not sure and could use a push in the right direction. Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Either you can let the sessions "own" their views, or you can just add a check when processing the payment, if it's already been paid.

Share this post


Link to post
Share on other sites
Basically, I just take the view that any data that can alter between views, will alter. So I check it for validity every time. It only feels like a hack when you're used to sequential programming where each section of code allows you to make large assumptions about the data state in future sections. Your database will have safe concurrency checks built in - rely on that to control access to resources and you should be fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!