Skip to content

Commit 6a1c7e4

Browse files
authored
Fixing BulkProcessor2RetryIT (#95091)
1 parent d43aa81 commit 6a1c7e4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessor2RetryIT.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.action.DocWriteRequest;
1313
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
1414
import org.elasticsearch.action.search.SearchResponse;
15+
import org.elasticsearch.client.Client;
1516
import org.elasticsearch.common.settings.Settings;
1617
import org.elasticsearch.core.Tuple;
1718
import org.elasticsearch.index.query.QueryBuilders;
@@ -34,6 +35,12 @@
3435
public class BulkProcessor2RetryIT extends ESIntegTestCase {
3536
private static final String INDEX_NAME = "test";
3637
Map<String, Integer> requestToExecutionCountMap = new ConcurrentHashMap<>();
38+
/*
39+
* We can't call ESIntegTestCase.client() from a transport thread because it winds up calling a blocking operation that trips an
40+
* assertion error if you're doing it from the transport thread. So we stash a random client in this variable for use when we nned a
41+
* client in a transport thread.
42+
*/
43+
private Client clientsForTransportThread;
3744

3845
@Override
3946
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
@@ -58,14 +65,14 @@ public void testBulkRejectionLoadWithoutBackoff() throws Throwable {
5865
// value = "org.elasticsearch.action.bulk.Retry2:trace",
5966
// reason = "Logging information about locks useful for tracking down deadlock"
6067
// )
61-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/94941")
6268
public void testBulkRejectionLoadWithBackoff() throws Throwable {
6369
boolean rejectedExecutionExpected = false;
6470
executeBulkRejectionLoad(8, rejectedExecutionExpected);
6571
}
6672

6773
@SuppressWarnings("unchecked")
6874
private void executeBulkRejectionLoad(int maxRetries, boolean rejectedExecutionExpected) throws Throwable {
75+
clientsForTransportThread = client();
6976
int numberOfAsyncOps = randomIntBetween(600, 700);
7077
final CountDownLatch latch = new CountDownLatch(numberOfAsyncOps);
7178
final Set<BulkResponse> successfulResponses = Collections.newSetFromMap(new ConcurrentHashMap<>());
@@ -110,6 +117,8 @@ public void afterBulk(long executionId, BulkRequest request, Exception failure)
110117
}
111118
rejectedAfterAllRetries = true;
112119
}
120+
} else if (failure.getStatus() == RestStatus.SERVICE_UNAVAILABLE) {
121+
// The test framework throws this at us sometimes
113122
} else {
114123
throw new AssertionError("Unexpected failure status: " + failure.getStatus());
115124
}
@@ -128,6 +137,8 @@ public void afterBulk(long executionId, BulkRequest request, Exception failure)
128137
rejectedAfterAllRetries = true;
129138
}
130139
// ignored, we exceeded the write queue size when dispatching the initial bulk request
140+
} else if (ExceptionsHelper.status(failureTuple.v2()) == RestStatus.SERVICE_UNAVAILABLE) {
141+
// The test framework throws this at us sometimes
131142
} else {
132143
Throwable t = failureTuple.v2();
133144
// we're not expecting any other errors
@@ -164,7 +175,7 @@ void countAndBulk(BulkRequest request, ActionListener<BulkResponse> listener) {
164175
for (DocWriteRequest<?> docWriteRequest : request.requests) {
165176
requestToExecutionCountMap.compute(docWriteRequest.id(), (key, value) -> value == null ? 1 : value + 1);
166177
}
167-
client().bulk(request, listener);
178+
clientsForTransportThread.bulk(request, listener);
168179
}
169180

170181
}

0 commit comments

Comments
 (0)