### Elasticsearch Version

8.6.0-SNAPSHOT

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

N/A

### Problem Description

We see 8.6.0 master nodes (512MB heap) repeatedly dying with OOME when attempting to do a snapshot with GCS snapshot repository. This is not reproducible with prior versions and we suspect that this is caused by https://github.com/elastic/elasticsearch/pull/90282.

### Steps to Reproduce

1. Start a cluster in a containerized environment; master nodes have 1GB of memory, 512MB of heap
2. Setup a GCS snapshot repository
3. Create a snapshot of the cluster.
4. The master node will OOM with the following message:

```
[5383.050s][warning][gc,alloc] elasticsearch[i6][snapshot][T#26]: Retried waiting for GCLocker too often allocating 256 words
[5383.053s][warning][gc,alloc] elasticsearch[i6][snapshot][T#14]: Retried waiting for GCLocker too often allocating 1029 words
java.lang.OutOfMemoryError: Java heap space
```

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java
}
    public static boolean assertCurrentThreadPool(String... permittedThreadPoolNames) {
        final var threadName = Thread.currentThread().getName();
        assert threadName.startsWith("TEST-")
            || threadName.startsWith("LuceneTestCase")
            || Arrays.stream(permittedThreadPoolNames).anyMatch(n -> threadName.contains('[' + n + ']'))
            : threadName + " not in " + Arrays.toString(permittedThreadPoolNames) + " nor a test thread";
        return true;
    }
    public static boolean assertInSystemContext(ThreadPool threadPool) {
        final var threadName = Thread.currentThread().getName();
        assert threadName.startsWith("TEST-") || threadName.startsWith("LuceneTestCase") || threadPool.getThreadContext().isSystemContext()
            : threadName + " is not running in the system context nor a test thread";
        return true;
    }
    public static boolean assertCurrentMethodIsNotCalledRecursively() {
        final StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
        assert stackTraceElements.length >= 3 : stackTraceElements.length;
        assert stackTraceElements[0].getMethodName().equals("getStackTrace") : stackTraceElements[0];
        assert stackTraceElements[1].getMethodName().equals("assertCurrentMethodIsNotCalledRecursively") : stackTraceElements[1];
        final StackTraceElement testingMethod = stackTraceElements[2];
        for (int i = 3; i < stackTraceElements.length; i++) {
            assert stackTraceElements[i].getClassName().equals(testingMethod.getClassName()) == false
                || stackTraceElements[i].getMethodName().equals(testingMethod.getMethodName()) == false
                : testingMethod.getClassName() + "#" + testingMethod.getMethodName() + " is called recursively";
        }
        return true;
    }
}