### CI Link

https://gradle-enterprise.elastic.co/s/hecpxrqifdmsk

### Repro line

./gradlew ':x-pack:plugin:core:test' --tests "org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal" -Dtests.seed=9ECCB8D6E10EF388

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

First discovered Aug 29/2023.

### Failure excerpt

```
❯ ./gradlew ':x-pack:plugin:core:test' --tests "org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal" -Dtests.seed=9ECCB8D6E10EF388

> Configure project :x-pack:plugin:searchable-snapshots:qa:hdfs
hdfsFixture unsupported, please set HADOOP_HOME and put HADOOP_HOME\bin in PATH
=======================================
Elasticsearch Build Hamster says Hello!
  Gradle Version        : 8.2
  OS Info               : Mac OS X 13.5.1 (aarch64)
  JDK Version           : 17.0.7+7 (Eclipse Temurin)
  JAVA_HOME             : /Users/john.verwolf/.sdkman/candidates/java/17.0.7-tem
  Random Testing Seed   : 9ECCB8D6E10EF388
  In FIPS 140 mode      : false
=======================================

> Task :x-pack:plugin:core:test
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.gradle.api.internal.tasks.testing.worker.TestWorker (file:/Users/john.verwolf/.gradle/wrapper/dists/gradle-8.2-all/6mxqtxovn2faat1idb7p6lxsa/gradle-8.2/lib/plugins/gradle-testing-base-8.2.jar)
WARNING: Please consider reporting this to the maintainers of org.gradle.api.internal.tasks.testing.worker.TestWorker
WARNING: System::setSecurityManager will be removed in a future release

REPRODUCE WITH: ./gradlew ':x-pack:plugin:core:test' --tests "org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal" -Dtests.seed=9ECCB8D6E10EF388 -Dtests.locale=es-AR -Dtests.timezone=America/Inuvik -Druntime.java=20

org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests > testRestoreMinimal FAILED
    junit.framework.AssertionFailedError: Unexpected exception type, expected EngineException but got java.lang.RuntimeException: field: _seq_no has docvalues but should omit them!
        at __randomizedtesting.SeedInfo.seed([9ECCB8D6E10EF388:B2455D9853989350]:0)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2869)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2850)
        at org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal(SourceOnlySnapshotShardTests.java:389)

        Caused by:
        java.lang.RuntimeException: field: _seq_no has docvalues but should omit them!
            at org.apache.lucene.tests.util.TestUtil.checkReaderSanity(TestUtil.java:422)
            at org.apache.lucene.tests.util.TestUtil.checkReader(TestUtil.java:389)
            at org.apache.lucene.tests.util.TestUtil.checkReader(TestUtil.java:364)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1949)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1921)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1910)
            at org.elasticsearch.index.engine.EngineTestCase$MatchingDirectoryReader$1.wrap(EngineTestCase.java:1516)
            at org.apache.lucene.index.FilterDirectoryReader$SubReaderWrapper.wrap(FilterDirectoryReader.java:61)
            at org.apache.lucene.index.FilterDirectoryReader.<init>(FilterDirectoryReader.java:91)
            at org.elasticsearch.index.engine.EngineTestCase$MatchingDirectoryReader.<init>(EngineTestCase.java:1512)
            at org.elasticsearch.index.engine.EngineTestCase.lambda$randomReaderWrapper$15(EngineTestCase.java:1570)
            at org.elasticsearch.index.shard.IndexShard.wrapSearcher(IndexShard.java:1589)
            at org.elasticsearch.index.shard.IndexShard.wrapSearcher(IndexShard.java:1560)
            at org.elasticsearch.index.engine.Engine$SearcherSupplier.acquireSearcher(Engine.java:1336)
            at org.elasticsearch.index.engine.Engine.acquireSearcher(Engine.java:789)
            at org.elasticsearch.index.engine.ReadOnlyEngine.get(ReadOnlyEngine.java:281)
            at org.elasticsearch.index.shard.IndexShard.innerGet(IndexShard.java:1232)
            at org.elasticsearch.index.shard.IndexShard.get(IndexShard.java:1212)
            at org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.lambda$testRestoreMinimal$7(SourceOnlySnapshotShardTests.java:391)
            at org.apache.lucene.tests.util.LuceneTestCase._expectThrows(LuceneTestCase.java:3022)
            at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2859)
            ... 2 more


Suite: Test class org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests
  1> [2023-08-29T12:31:58,963][INFO ][o.e.s.s.SourceOnlySnapshotShardTests] [testRestoreMinimal] before test
  2> ago 29, 2023 12:31:59 PM org.apache.lucene.store.MemorySegmentIndexInputProvider <init>
  2> INFO: Using MemorySegmentIndexInput with Java 20; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false
  1> [2023-08-29T12:32:00,877][INFO ][o.e.i.r.RecoverySettings ] [testRestoreMinimal] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
  1> [2023-08-29T12:32:01,144][INFO ][o.e.s.s.SourceOnlySnapshotShardTests] [testRestoreMinimal] after test
  2> REPRODUCE WITH: ./gradlew ':x-pack:plugin:core:test' --tests "org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal" -Dtests.seed=9ECCB8D6E10EF388 -Dtests.locale=es-AR -Dtests.timezone=America/Inuvik -Druntime.java=20
  2> junit.framework.AssertionFailedError: Unexpected exception type, expected EngineException but got java.lang.RuntimeException: field: _seq_no has docvalues but should omit them!
        at __randomizedtesting.SeedInfo.seed([9ECCB8D6E10EF388:B2455D9853989350]:0)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2869)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2850)
        at org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal(SourceOnlySnapshotShardTests.java:389)

        Caused by:
        java.lang.RuntimeException: field: _seq_no has docvalues but should omit them!
            at org.apache.lucene.tests.util.TestUtil.checkReaderSanity(TestUtil.java:422)
            at org.apache.lucene.tests.util.TestUtil.checkReader(TestUtil.java:389)
            at org.apache.lucene.tests.util.TestUtil.checkReader(TestUtil.java:364)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1949)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1921)
            at org.apache.lucene.tests.util.LuceneTestCase.newSearcher(LuceneTestCase.java:1910)
            at org.elasticsearch.index.engine.EngineTestCase$MatchingDirectoryReader$1.wrap(EngineTestCase.java:1516)
            at org.apache.lucene.index.FilterDirectoryReader$SubReaderWrapper.wrap(FilterDirectoryReader.java:61)
            at org.apache.lucene.index.FilterDirectoryReader.<init>(FilterDirectoryReader.java:91)
            at org.elasticsearch.index.engine.EngineTestCase$MatchingDirectoryReader.<init>(EngineTestCase.java:1512)
            at org.elasticsearch.index.engine.EngineTestCase.lambda$randomReaderWrapper$15(EngineTestCase.java:1570)
            at org.elasticsearch.index.shard.IndexShard.wrapSearcher(IndexShard.java:1589)
            at org.elasticsearch.index.shard.IndexShard.wrapSearcher(IndexShard.java:1560)
            at org.elasticsearch.index.engine.Engine$SearcherSupplier.acquireSearcher(Engine.java:1336)
            at org.elasticsearch.index.engine.Engine.acquireSearcher(Engine.java:789)
            at org.elasticsearch.index.engine.ReadOnlyEngine.get(ReadOnlyEngine.java:281)
            at org.elasticsearch.index.shard.IndexShard.innerGet(IndexShard.java:1232)
            at org.elasticsearch.index.shard.IndexShard.get(IndexShard.java:1212)
            at org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.lambda$testRestoreMinimal$7(SourceOnlySnapshotShardTests.java:391)
            at org.apache.lucene.tests.util.LuceneTestCase._expectThrows(LuceneTestCase.java:3022)
            at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2859)
            ... 2 more
  2> NOTE: leaving temporary files on disk at: /Users/john.verwolf/code/elasticsearch/x-pack/plugin/core/build/testrun/test/temp/org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests_9ECCB8D6E10EF388-003
  2> NOTE: test params are: codec=Asserting(Lucene95): {}, docValues:{}, maxPointsInLeafNode=884, maxMBSortInHeap=5.286531931746483, sim=Asserting(RandomSimilarity(queryNorm=false): {}), locale=es-AR, timezone=America/Inuvik
  2> NOTE: Mac OS X 13.5.1 aarch64/Oracle Corporation 20.0.1 (64-bit)/cpus=10,threads=1,free=248952144,total=536870912
  2> NOTE: All tests run in this JVM: [SourceOnlySnapshotShardTests]

Tests with failures:
 - org.elasticsearch.snapshots.sourceonly.SourceOnlySnapshotShardTests.testRestoreMinimal

1 test completed, 1 failed

> Task :x-pack:plugin:core:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':x-pack:plugin:core:test'.
> There were failing tests. See the report at: file:///Users/john.verwolf/code/elasticsearch/x-pack/plugin/core/build/reports/tests/test/index.html

BUILD FAILED in 13s
104 actionable tasks: 1 executed, 103 up-to-date

Publishing build scan...
https://gradle-enterprise.elastic.co/s/hecpxrqifdmsk
```
test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java
public static MappingLookup mappingLookup() {
        try {
            return createMapperService().mappingLookup();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
    /**
     * Exposes a translog associated with the given engine for testing purpose.
     */
    public static Translog getTranslog(Engine engine) {
        assert engine instanceof InternalEngine : "only InternalEngines have translogs, got: " + engine.getClass();
        InternalEngine internalEngine = (InternalEngine) engine;
        return internalEngine.getTranslog();
    }
    /**
     * Waits for all operations up to the provided sequence number to complete in the given internal engine.
     *
     * @param seqNo the sequence number that the checkpoint must advance to before this method returns
     * @throws InterruptedException if the thread was interrupted while blocking on the condition
     */
    public static void waitForOpsToComplete(InternalEngine engine, long seqNo) throws Exception {
        assertBusy(() -> assertThat(engine.getLocalCheckpointTracker().getProcessedCheckpoint(), greaterThanOrEqualTo(seqNo)));
    }
    public static boolean hasSnapshottedCommits(Engine engine) {
        assert engine instanceof InternalEngine : "only InternalEngines have snapshotted commits, got: " + engine.getClass();
        InternalEngine internalEngine = (InternalEngine) engine;
        return internalEngine.hasSnapshottedCommits();
    }
    public static final class PrimaryTermSupplier implements LongSupplier {