Fix race condition that may occur when creating identities with same canonical value