Switch auto-ids to Flake IDs from random UUIDs

This PR starts from @GaelTadh's original PR (#6004) and just folds in the last round of feedback ... I think it's ready?
Maybe this method should be synchronized so that we can ensure that ids are actually monotonically increasing? The code in the synchronized block should be very fast (we can put the call to System.currentTimeMillis outside of it) so this would very unlikely be a bottleneck?