[Xapian-devel] buffered tables, sessions, and transactions

Olly Betts olly at survex.com
Wed May 19 13:15:50 BST 2004


On Wed, May 19, 2004 at 12:36:05PM +0100, Richard Boulton wrote:
> Olly Betts wrote:
> >Unfortunately, begin_transaction also needs to flush (so we can
> >implement cancel_transaction, at least in the design I sketched out).
> >So this doesn't help a series of transcations - only the last flush is
> >avoided, and only if there are non-transactional changes after the
> >series of transactions.
> 
> Ah yes, that makes sense.  I agree, then, that supporting 
> commit_transaction isn't actually very important, and that implementing 
> end_transaction as you suggest would be a sensible approach.

I've noticed a slight wrinkle - currently if a database is destroyed
with an active transaction, cancel_transaction is called.  Without
this method, if an error is thrown part way through a transaction,
either we apply the whole lot, or lose everything since the last call to
flush() (explicit or implicit).  That could be several transactions, so
at least this preserves atomicity better than just flushing.

Perhaps we should *always* require a call to flush() (or a new close()
method) before a database is destroyed?  At present, any errors thrown
by the implicit flush() in the destructor are caught and ignored, which
isn't ideal at all.

However, that's an API change, and seems to be deliberately setting a
trap for the unwary...

Cheers,
    Olly




More information about the Xapian-devel mailing list