Suppose my server PHP end point follows something along the lines of the following:
- Client sends request to server.
- Server updates a record
- Server might do some PHP processing...
- Server updates record again
What to do if the server crashes whilst performing either of the SQL commands (either 2 or 4) or during 3.
Is it just a case that I need to code defensively, making sure that I'm aware of the consequences of each possible result of a crash at critical code areas, i.e. to perform a sort of crash analysis to determine the worst outcomes, and make sure my work flow is able to deal with each case.
Or is there some other mechanism I can use to help with such cases?