Restructured code to retry failed transactions.
Restructured code to retry failed transactions.

Previously, code was written assuming that tx.commit() always succeeds,
expecting to later add some minimal code to check for failure and retry
if necessary. This commit adds that retry mechanism.

PlatformLab/Ramdis,PlatformLab/Ramdis,PlatformLab/Ramdis