Avoiding duplicated transaction on failure