What is the term for a function that can resume from error?

28 views Asked by At

I'm looking for a single word term for a property that program functions can have.

Common to long-running SQL scripts, which may fail or crash: if written without this property, such scripts can crash part-way through. Once such a script does so, the only resolution is to find where the program crashed, then manually adapting the code to start from that point.

But if written with the property, a crashed script (due to, for example, power loss), can be simply re-started and will result in the same state as if it ran to completion.

For example, doing:

INSERT INTO `customers` (`id`, `name`) VALUES ('1', 'Stephenson')
INSERT INTO `customers` (`id`, `name`) VALUES ('2', 'Boulton')

versus:

INSERT INTO `customers` (`id`, `name`) VALUES ('1', 'Stephenson') ON DUPLICATE KEY UPDATE `name`='Stephenson'
INSERT INTO `customers` (`id`, `name`) VALUES ('2', 'Boulton') ON DUPLICATE KEY UPDATE `name`='Boulton'

(Of course, this example is a bit pathological as there are only two records, but if there are millions, it makes more sense).

What is the word for this?

1

There are 1 answers

0
npr_se On

The comment by VLL pointed me to the right answer, indicated on the wiki page linked;

Idempotence

In which the result of running the function twice, or a part of it twice, is the same as running it once. Reentrancy only requires that the function doesn't error, idempotence is somewhat stronger in that it not only won't error, the end-result of 'resuming' by re-running the function has to be exactly the same as running it once-through, which is generally the intention. if my 'safe' sql inserts twice the amount of bills that it should in the database if the server crashes and restarts, the customer will complain, even though there technically 'weren't any errors'.

The exact difference is rather small, parallel to Pleonasm vs. Tautology, there's a lot of overlap.