So apparently running an INSERT/UPDATE on a transaction doesn't actually guarantee atomicity. So we use retry.