legoscia
legoscia

Reputation: 41648

Mnesia: when would you limit the number of transaction retries?

Mnesia lets you limit the number of times it retries a transaction:

MyFun = fun() -> ... end,
{atomic, ok} = mnesia:transaction(MyFun, [], 42)

If you don't specify a number, it defaults to infinity.

I've never seen any code that actually limits the number of retries. Have you? In what cases is it useful?

Upvotes: 1

Views: 238

Answers (1)

Muzaaya Joshua
Muzaaya Joshua

Reputation: 7836

You may limit the number of retries when you are implementing soft real-time systems in which certain operations have to occur within a defined duration of time or at a specified time and if they don't, another action must be taken.

In such a case, you do not want other processes to wait while not being sure whether the transaction has been successful. However, several transaction contexts of mnesia may change the way transaction commits are done in your application.

However, in my personal experience, real-time systems with mnesia ought to be handled using mnesia events, whereby, any write, update, delete, insert, e.t.c generates an instantaneous Event to all subscribed Processes/Servers, there and then. So those who receive this event message would take any action they desire possible.

Upvotes: 1

Related Questions