Making id incrementation atomic