Make default uuid generation random (uuid4), not based on counter.
Make counter incrementing more atomic, to avoid race conditions.
Move the old version of get_uuid into the new method, for reference.
Merge pull request #2818 from jamalex/fix_uuid_race_conditions

Fix UUID race conditions