I'm currently working on a very preliminary implementation of the journal. It is an interceptor added at the very end of the chain, just before the partition. the way it works is very simple :
- it logs the LDIF for every modification in the journal, plus some extra informations (Ldapprincipal, a timestamp and a revision number). This is done before calling the partition Add method
- when the entry has been added into the partition, an ACK is logged into the journal, as a comment, containing the revision of the ACKed operation.
- if the addition failed, a NACK is logged in the same way
- the written information are immediately flushed on disk, and the write operation is synchronized in order to avoid a mixup of operations in the file.
Here is an exemple of what we get :
# ts: 1235862542574
# rev: 1235862541942
# ack-rev: 1235862541942
# ts: 1235862542618
# rev: 1235862541943
# ack-rev: 1235862541943
The revision number is used to associate a ack/nack to an operation : if the server crashes in the middle of a partition update, we won't have a ack/nack for the pending operation.
As you can see, this is a very basic implementation atm. I didn't dealt with all the intricacy of journal rotation, journal cleanup, and such. It's a growing file, and it can grow fast. Some immediate improvement could be to use more than one file to store the changes, with an executor to deal with the write, allowing parallel update of the journal (it would be a bit more complicated to restore the journal, but at least, we would avoid a contention problem).
So wdyt about this first version ? What's missing ?