I would caution that a two-phase commit is not always the best you can do. A two-phase commit is blocking and in event of failure during processing it can cause a deadlock. A three-phase commit offers the same level of guarantee but without blocking.