diff --git a/muted-tests.yml b/muted-tests.yml index e1612b941fc06..d4d1e4dfbc6ec 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -444,9 +444,6 @@ tests: - class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT method: test {p0=esql/120_profile/avg 8.14 or after} issue: https://github.com/elastic/elasticsearch/issues/127879 -- class: org.elasticsearch.indices.stats.IndexStatsIT - method: testThrottleStats - issue: https://github.com/elastic/elasticsearch/issues/126359 - class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests method: testRandomWithFilter issue: https://github.com/elastic/elasticsearch/issues/127963 diff --git a/server/src/main/java/org/elasticsearch/index/engine/Engine.java b/server/src/main/java/org/elasticsearch/index/engine/Engine.java index de8bfd0e3e61c..19c4ef852286e 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -612,7 +612,6 @@ public Condition newCondition() { } public void throttle() { - assert semaphore.availablePermits() == Integer.MAX_VALUE; semaphore.acquireUninterruptibly(Integer.MAX_VALUE - allowThreads); } diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index bc63ef763ec57..f52e753a5ad9f 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -162,6 +162,7 @@ import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.Executors; import java.util.concurrent.Phaser; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; @@ -7686,6 +7687,23 @@ public void testDisableRecoverySource() throws Exception { } } + public void testPauseLockCanBeThrottledConcurrently() throws Exception { + int allowThreads = randomIntBetween(2, 8); + var pauseLock = new Engine.PauseLock(allowThreads); + var executor = Executors.newFixedThreadPool(allowThreads); + var barrier = new CyclicBarrier(allowThreads); + for (int i = 0; i < allowThreads; i++) { + executor.submit(() -> { + safeAwait(barrier); + pauseLock.throttle(); + pauseLock.unthrottle(); + }); + } + + executor.shutdown(); + assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS)); + } + private static void assertCommitGenerations(Map commits, List expectedGenerations) { assertCommitGenerations(commits.values().stream().map(Engine.IndexCommitRef::getIndexCommit).toList(), expectedGenerations); }