This project has moved. For the latest updates, please go here.

how to use ensure durable commit?

Jun 20, 2014 at 11:36 PM
I'm a little confused with how to use the CommitTransactionGrbit to ensure a durable commit. The enumeration has 3 values:

LazyFlush - obviously not what I'm looking for.
None - The documentation simply says "default options", and does not say whether the default is lazy or not.
WaitLastLevel0Commit - I tried this, and it doesn't seem to commit anything. I suppose the "last level 0 commit" refers to the commit prior to the current one.

Can anyone clarify?

Thanks!
Developer
Jun 20, 2014 at 11:43 PM
You want 'None'. That's the regular durable commit.

WaitLastLevel0Commit is useful for doing things like many inserts:
foreach ( Bla bla in blas )
{
  BeginTransaction();
  Commit( Lazy ); // does not wait for the disk to flush.
}
Commit( WaitLastLevel0Commit ); // waits for the disk to flush.
// Now it's guaranteed that everything is flushed to the disk, ensuring disk consistency.
If there are 100 elements, and you crash at the 50th element, then the log stream may have only data for the first 10 (maybe even none). The tradeoff is durability-versus-speed. Many times this is perfectly acceptable. But people still want some durability guarantees.

Does that make sense?

-martin
Marked as answer by jr76 on 6/21/2014 at 7:20 AM
Jun 21, 2014 at 2:20 PM
Yes, makes perfect sense. I figured that 'None' was probably what I was looking for, but I didn't want to make any assumptions (especially since in my testing, there was no performance difference between using None and Lazy, which caused me to wonder if in fact Lazy was the default...).

Thanks Martin!