def attempt_change(action, source_db, target_db, diff, remaining_attempts)
begin
rep_helper.session.send(target_db).execute "savepoint rr_#{action}_#{remaining_attempts}"
yield
unless rep_helper.new_transaction?
rep_helper.session.send(target_db).execute "release savepoint rr_#{action}_#{remaining_attempts}"
end
rescue Exception => e
rep_helper.session.send(target_db).execute "rollback to savepoint rr_#{action}_#{remaining_attempts}"
diff.amend
replicate_difference diff, remaining_attempts - 1,
"#{action} failed with #{e.message}"
end
end