directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <>
Subject [Mavibot] Transaction discussion
Date Fri, 07 Feb 2014 10:12:08 GMT

there are two things to consider in order to support transactions :

- we could have automatique transaction per operation (ie, we don't have
to start a transaction before issuing an operation)
- we can also create a transaction explicitely, and use it across more
than one operation.

We want to support both cases.

This is not trivial, as we want to make it as easy as possible for our
users. Typically, how should an operation know which kind of transaction
it is dealing with ? Let's have a look at such an operation :

insert :
    // check if we are already into a txn
    if (in transaction)        (1)
            process operation
            start transaction  (2)
            process operation
            commit operation

so far, it seems ok, but what if another thread has started a
transaction *just* after the test (1) and before (2) ? This is complicated.

One easy solution would be to pass a transaction as a parameter. If this
parameter is null, then we can start a new transaction (but again, we
will have difficulties if we have to check if this parameter is null
inside the operation, for the exact same reason thanseen before).

At the end of teh day, it's probably better to force people to create
the transaction *before* starting an operation :

txn = begingTransaction()
insert( txn )

That's not really beautiful, but it will be safe. I'm also trying to
think about other options...

View raw message