**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
final ProfileService.VersionedDocument versionedDocument1 = future1.actionGet();
        assertThat(versionedDocument1, notNullValue());
        assertThat(versionedDocument1.doc().uid(), equalTo(uid1));
        
        
        
        final RealmDomain realmDomain1 = new RealmDomain("domainA", Set.of(realmIdentifier2));
        final Authentication authentication2 = new Authentication(
            new User("Foo"),
            new Authentication.RealmRef(realmIdentifier2.getName(), realmIdentifier2.getType(), nodeName, realmDomain1),
            null
        );
        final Subject subject2 = AuthenticationContext.fromAuthentication(authentication2).getEffectiveSubject();
        final PlainActionFuture<ProfileService.VersionedDocument> future2 = new PlainActionFuture<>();
        profileService.searchVersionedDocumentForSubject(subject2, future2);
        assertThat(future2.actionGet(), nullValue());
        
        
        final Authentication authentication3 = new Authentication(
            new User("Foo"),
            new Authentication.RealmRef(realmIdentifier2.getName(), realmIdentifier2.getType(), nodeName),
            null
        );
        final Subject subject3 = AuthenticationContext.fromAuthentication(authentication3).getEffectiveSubject();
        final PlainActionFuture<ProfileService.VersionedDocument> future3 = new PlainActionFuture<>();
        profileService.searchVersionedDocumentForSubject(subject3, future3);
        assertThat(future3.actionGet(), nullValue());
    }
    public void testGetProfileByAuthenticationWillNotCheckRealmNameForFileOrNativeRealm() {