**Build scan:**
https://gradle-enterprise.elastic.co/s/nmjznurkclizw/tests/:x-pack:plugin:security:internalClusterTest/org.elasticsearch.xpack.security.profile.ProfileDomainIntegTests/testConcurrentCreationOfNewProfiles

**Reproduction line:**
`./gradlew ':x-pack:plugin:security:internalClusterTest' --tests "org.elasticsearch.xpack.security.profile.ProfileDomainIntegTests.testConcurrentCreationOfNewProfiles" -Dtests.seed=DF7A58E7374EF2C7 -Dtests.locale=id-ID -Dtests.timezone=Europe/Ljubljana -Druntime.java=17`

**Applicable branches:**
master

**Reproduces locally?:**
No

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.security.profile.ProfileDomainIntegTests&tests.test=testConcurrentCreationOfNewProfiles

**Failure excerpt:**
```
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=339, name=Thread-17, state=RUNNABLE, group=TGRP-ProfileDomainIntegTests]


  Caused by: java.lang.AssertionError: caught error when creating new profile: org.elasticsearch.action.UnavailableShardsException: at least one primary shard for the index [.security-profile-8] is unavailable

    at __randomizedtesting.SeedInfo.seed([DF7A58E7374EF2C7]:0)
    at org.junit.Assert.fail(Assert.java:88)
    at org.elasticsearch.xpack.security.profile.ProfileDomainIntegTests.lambda$testConcurrentCreationOfNewProfiles$0(ProfileDomainIntegTests.java:321)
    at java.lang.Thread.run(Thread.java:833)

```
x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileDomainIntegTests.java
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
        final Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
        
        builder.put("xpack.security.authc.domains.my_domain.realms", "file,index");
        return builder.build();
    }
    public void testActivateProfileUnderDomain() {
        
        final Profile profile1 = doActivateProfile(RAC_USER_NAME, TEST_PASSWORD_SECURE_STRING);
        assertThat(profile1.user().username(), equalTo(RAC_USER_NAME));
        assertThat(profile1.user().realmName(), equalTo("file"));
        assertThat(profile1.user().domainName(), equalTo("my_domain"));
        assertThat(profile1.user().email(), nullValue());
        assertThat(profile1.user().fullName(), nullValue());
        
        assertThat(getProfile(profile1.uid(), Set.of()), equalTo(profile1));
        
        
        final Profile profile2 = doActivateProfile(RAC_USER_NAME, NATIVE_RAC_USER_PASSWORD);
        assertThat(profile2.uid(), equalTo(profile1.uid()));
        assertThat(profile2.user().username(), equalTo(RAC_USER_NAME));
        assertThat(profile2.user().realmName(), equalTo("index"));
        assertThat(profile2.user().domainName(), equalTo("my_domain"));
        assertThat(profile2.user().email(), equalTo(RAC_USER_NAME + "@example.com"));
        assertThat(profile2.user().fullName(), nullValue());
        assertThat(profile2.user().roles(), containsInAnyOrder(RAC_ROLE));
        
        
        final Profile profile3 = doActivateProfile(RAC_USER_NAME, TEST_PASSWORD_SECURE_STRING);
        assertThat(profile3.uid(), equalTo(profile1.uid()));