Database updates without race conditions