Is possible to make a non-idempotent function idempotent and resist to failures at the same time?

39 Views Asked by At

I try to design an idempotent function that would resist to failures in a concurrent system while making use of a non-idempotent one.

I've been able to get something working with a

if lockAcquired 
    then : execute the non-idempotent function 
           write result
    else : wait until result available
           read result
return result

But it assumes that the "writing" thread doesn't fail between acquiring the lock and writing the result.

Are there some known algorithm out there that solve this problem ? (I guess it would be a totally different approach)

In order to reason about the problem, an example of non-idempotent function would be "sending an email".

0

There are 0 best solutions below