Jump to content

Failed Deletes, Inserts, updates and database anomalies


keldorn

Recommended Posts

I tried searching for this, but could not find anything.  What if your application is very Acid, and say what happens if there is failed Query that could cause some serious database anomalies,  what would be best to deal with that?

 

 

Take for example you have 2 categories,  Foo and Bar,  Foo and bar ave each 1 Widget, in the table for the categories it lists how many widgets it has, so it would be

 

Foo (1)

bar (1)

 

Now say you do a SQL query and move the widget from bar to Foo, so in the database you update the widgets table and point its category to foo, then you update categories to decrement bar by 1 and increase Foo by 1, but here what happens is that query fails becuase at the point their some network outage on that remote mysql server, or mysql is too busy and accidental drops the UPdate or it get lost or something etc., and to make matters worse you have and die() on that query, so now    Both widets are listed in Foo , and the whole script process dies and it didn't update the categories, now you have an anomaly silently away in your DB!

foo (1)

bar (1)

 

But it should be

 

Foo (2)

Bar (0)

 

What would could be done to prevent this? Would you catch the failed queries and re-run them? or roll back the queries?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.