Can the race condition be prevented by starting a transaction before the first call and committing after the last one ?