atcroft has asked for the wisdom of the Perl Monks concerning the following question:

Respected monks, once again I come to thee with a question for which I seek your wisdom and guidance.

At present, I am involved in a project which requires multiple instances of the project spread across multiple systems to contact a centrally-located database containing the action to perform, and, once done, report the results of the actions.

My current quandries appear to boil down to a question-how can I write atomic or semi-atomic functions so a catastrophic failure has less of a chance of having dire consequences?

An example of the items I have considered thus far where I can see this ability to be advantageous include:

Because of the importance impressed upon me regarding this project, I have to assume there is the possibility of having to handle worst-case scenarios in which other safeguards (such as UPS systems or redundant switches) cannot be relied upon.

I have been trying to do some research into these, digging into the error handling subsection in Programming the Perl DBI, the Super Search, and such postings as The art of error handling.

I think I am correct in assuming that a 100 percent solution for operations requiring multiple processor instructions is not possible, and I do not discount the idea that there are some events which I cannot protect against. I also assume that eval and closures will also factor in (among other possibilities), but I have been known to be wrong before, so please correct me if I am barking up the wrong tree, or if I am even in the wrong forest.

Your attention and wisdom are greatly appreciated.

  • Comment on Regarding the writing of atomic or semi-atomic processes and instruction sequences

Replies are listed 'Best First'.
Re: Regarding the writing of atomic or semi-atomic processes and instruction sequences
by perrin (Chancellor) on Aug 29, 2002 at 18:32 UTC
    How can you write atomic functions so that failures won't have dire consequences? It's easy: use a database that supports transactions. The point of transactions is to guarantee that your data will never be left in a bad state.

    If your question is actually how can you make your system continue to function after some hardware fails, then you will have to delve into network architecture and failover technologies, but these don't have much to do with Perl. From the Perl side of things, you just try to do your work and if a transaction fails you handle it in an appropriate way (try again, notify the police, whatever).