Skip to content

Commit 8c9b2e3

Browse files
arteamlkts
authored andcommitted
Fix SimpleBlocksIT#testConcurrentAddBlock (elastic#126918)
Only one of concurrent `prepareAddBlock` calls actually wins a race to add the block, so we need to check `assertIndexHasBlock` if the add index block has been acknowledged Resolve elastic#122324 Co-authored-by: Oleksandr Kolomiiets <[email protected]>
1 parent 79efc9f commit 8c9b2e3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ tests:
143143
- class: org.elasticsearch.test.rest.ClientYamlTestSuiteIT
144144
method: test {yaml=snapshot.delete/10_basic/Delete a snapshot asynchronously}
145145
issue: https://github.com/elastic/elasticsearch/issues/122102
146-
- class: org.elasticsearch.blocks.SimpleBlocksIT
147-
method: testConcurrentAddBlock
148-
issue: https://github.com/elastic/elasticsearch/issues/122324
149146
- class: org.elasticsearch.action.admin.cluster.node.tasks.CancellableTasksIT
150147
method: testChildrenTasksCancelledOnTimeout
151148
issue: https://github.com/elastic/elasticsearch/issues/123568

server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,11 @@ public void testConcurrentAddBlock() throws InterruptedException, ExecutionExcep
413413
try {
414414
startInParallel(threadCount, i -> {
415415
try {
416-
indicesAdmin().prepareAddBlock(block, indexName).get();
417-
assertIndexHasBlock(block, indexName);
416+
AddIndexBlockResponse response = indicesAdmin().prepareAddBlock(block, indexName).get();
417+
// Check that the block has been added only for the request that won the race
418+
if (response.isAcknowledged() && response.getIndices().isEmpty() == false) {
419+
assertIndexHasBlock(block, indexName);
420+
}
418421
} catch (final ClusterBlockException e) {
419422
assertThat(e.blocks(), hasSize(1));
420423
assertTrue(e.blocks().stream().allMatch(b -> b.id() == block.getBlock().id()));

0 commit comments

Comments
 (0)