Skip to content

Commit 17ba4ac

Browse files
authored
Add test logging debug to SimpleBlocksIT.testAddBlockWhileIndexingDocuments (#74952) (#74979)
Relates #74345
1 parent 4828950 commit 17ba4ac

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
1414
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
1515
import org.elasticsearch.action.admin.indices.readonly.AddIndexBlockRequestBuilder;
16+
import org.elasticsearch.action.admin.indices.readonly.AddIndexBlockResponse;
1617
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequestBuilder;
1718
import org.elasticsearch.action.index.IndexRequestBuilder;
1819
import org.elasticsearch.action.index.IndexResponse;
@@ -28,6 +29,7 @@
2829
import org.elasticsearch.index.IndexNotFoundException;
2930
import org.elasticsearch.test.BackgroundIndexer;
3031
import org.elasticsearch.test.ESIntegTestCase;
32+
import org.elasticsearch.test.junit.annotations.TestLogging;
3133

3234
import java.util.ArrayList;
3335
import java.util.Arrays;
@@ -362,14 +364,16 @@ public void testConcurrentAddBlock() throws InterruptedException {
362364
}
363365
}
364366

367+
@TestLogging(
368+
reason = "https://github.com/elastic/elasticsearch/issues/74345",
369+
value = "org.elasticsearch.action.admin.indices.readonly:DEBUG,org.elasticsearch.cluster.metadata:DEBUG"
370+
)
365371
public void testAddBlockWhileIndexingDocuments() throws Exception {
366372
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
367373
createIndex(indexName);
368374

369375
final APIBlock block = randomAddableBlock();
370-
371376
int nbDocs = 0;
372-
373377
try {
374378
try (BackgroundIndexer indexer = new BackgroundIndexer(indexName, "_doc", client(), 1000)) {
375379
indexer.setFailureAssertion(t -> {
@@ -381,11 +385,11 @@ public void testAddBlockWhileIndexingDocuments() throws Exception {
381385
});
382386

383387
waitForDocs(randomIntBetween(10, 50), indexer);
384-
assertAcked(client().admin().indices().prepareAddBlock(block, indexName));
388+
final AddIndexBlockResponse response = client().admin().indices().prepareAddBlock(block, indexName).get();
389+
assertTrue("Add Index Block request was not acknowledged: " + response, response.isAcknowledged());
385390
indexer.stopAndAwaitStopped();
386391
nbDocs += indexer.totalIndexedDocs();
387392
}
388-
389393
assertIndexHasBlock(block, indexName);
390394
} finally {
391395
disableIndexBlock(indexName, block);

server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockResponse.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import org.elasticsearch.ElasticsearchException;
1111
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
1212
import org.elasticsearch.action.support.master.ShardsAcknowledgedResponse;
13-
import org.elasticsearch.core.Nullable;
1413
import org.elasticsearch.common.Strings;
1514
import org.elasticsearch.common.io.stream.StreamInput;
1615
import org.elasticsearch.common.io.stream.StreamOutput;
1716
import org.elasticsearch.common.io.stream.Writeable;
1817
import org.elasticsearch.common.util.CollectionUtils;
1918
import org.elasticsearch.common.xcontent.ToXContentFragment;
19+
import org.elasticsearch.common.xcontent.ToXContentObject;
2020
import org.elasticsearch.common.xcontent.XContentBuilder;
21+
import org.elasticsearch.core.Nullable;
2122
import org.elasticsearch.index.Index;
2223

2324
import java.io.IOException;
@@ -66,7 +67,7 @@ public String toString() {
6667
return Strings.toString(this);
6768
}
6869

69-
public static class AddBlockResult implements Writeable, ToXContentFragment {
70+
public static class AddBlockResult implements Writeable, ToXContentObject {
7071

7172
private final Index index;
7273
private final @Nullable Exception exception;

server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ public void innerOnFailure(final Exception e) {
644644

645645
private void processIfFinished() {
646646
if (countDown.countDown()) {
647-
onResponse.accept(new AddBlockResult(index, results.toArray(new AddBlockShardResult[results.length()])));
647+
AddBlockResult result = new AddBlockResult(index, results.toArray(new AddBlockShardResult[results.length()]));
648+
logger.debug("result of applying block to index {}: {}", index, result);
649+
onResponse.accept(result);
648650
}
649651
}
650652
});
@@ -885,7 +887,6 @@ static Tuple<ClusterState, Collection<AddBlockResult>> finalizeBlock(final Clust
885887
logger.debug("verification of shards before blocking {} failed [{}]", index, result);
886888
continue;
887889
}
888-
final IndexMetadata indexMetadata = metadata.getSafe(index);
889890
final ClusterBlock tempBlock = blockedIndices.get(index);
890891
assert tempBlock != null;
891892
assert tempBlock.uuid() != null;

0 commit comments

Comments
 (0)