Skip to content

Commit 92cb5f1

Browse files
ywangdDaveCTurner
andauthored
[7.17] More verbose logging in IndicesSegmentsRestCancellationIT (#113844) (#120025)
* More verbose logging in `IndicesSegmentsRestCancellationIT` (#113844) Relates #88201 (cherry picked from commit cd42719) * Fix logger reference * Use String instead of Strings --------- Co-authored-by: David Turner <[email protected]>
1 parent 6966bdb commit 92cb5f1

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/BlockedSearcherRestCancellationTestCase.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
package org.elasticsearch.http;
1010

11+
import org.apache.logging.log4j.LogManager;
12+
import org.apache.logging.log4j.Logger;
13+
import org.elasticsearch.ElasticsearchException;
1114
import org.elasticsearch.action.support.PlainActionFuture;
1215
import org.elasticsearch.client.Cancellable;
1316
import org.elasticsearch.client.Request;
@@ -34,6 +37,7 @@
3437
import java.util.ArrayList;
3538
import java.util.Collection;
3639
import java.util.List;
40+
import java.util.Locale;
3741
import java.util.Optional;
3842
import java.util.concurrent.CancellationException;
3943
import java.util.concurrent.Semaphore;
@@ -134,6 +138,12 @@ public List<Setting<?>> getSettings() {
134138

135139
private static class SearcherBlockingEngine extends ReadOnlyEngine {
136140

141+
// using a specialized logger for this case because and "logger" means "Engine#logger"
142+
// (relates investigation into https://github.com/elastic/elasticsearch/issues/88201)
143+
private static final Logger blockedSearcherRestCancellationTestCaseLogger = LogManager.getLogger(
144+
BlockedSearcherRestCancellationTestCase.class
145+
);
146+
137147
final Semaphore searcherBlock = new Semaphore(1);
138148

139149
SearcherBlockingEngine(EngineConfig config) {
@@ -142,12 +152,38 @@ private static class SearcherBlockingEngine extends ReadOnlyEngine {
142152

143153
@Override
144154
public Searcher acquireSearcher(String source, SearcherScope scope, Function<Searcher, Searcher> wrapper) throws EngineException {
155+
if (blockedSearcherRestCancellationTestCaseLogger.isDebugEnabled()) {
156+
blockedSearcherRestCancellationTestCaseLogger.debug(
157+
String.format(
158+
Locale.ROOT,
159+
"in acquireSearcher for shard [%s] on thread [%s], availablePermits=%d",
160+
config().getShardId(),
161+
Thread.currentThread().getName(),
162+
searcherBlock.availablePermits()
163+
),
164+
new ElasticsearchException("stack trace")
165+
);
166+
}
167+
145168
try {
146169
searcherBlock.acquire();
147170
} catch (InterruptedException e) {
148171
throw new AssertionError(e);
149172
}
150173
searcherBlock.release();
174+
175+
if (blockedSearcherRestCancellationTestCaseLogger.isDebugEnabled()) {
176+
blockedSearcherRestCancellationTestCaseLogger.debug(
177+
String.format(
178+
Locale.ROOT,
179+
"continuing in acquireSearcher for shard [%s] on thread [%s], availablePermits=%d",
180+
config().getShardId(),
181+
Thread.currentThread().getName(),
182+
searcherBlock.availablePermits()
183+
)
184+
);
185+
}
186+
151187
return super.acquireSearcher(source, scope, wrapper);
152188
}
153189
}

qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/IndicesSegmentsRestCancellationIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@
1111
import org.apache.http.client.methods.HttpGet;
1212
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsAction;
1313
import org.elasticsearch.client.Request;
14+
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
1415

1516
public class IndicesSegmentsRestCancellationIT extends BlockedSearcherRestCancellationTestCase {
17+
@TestIssueLogging(
18+
issueUrl = "https://github.com/elastic/elasticsearch/issues/88201",
19+
value = "org.elasticsearch.http.BlockedSearcherRestCancellationTestCase:DEBUG"
20+
+ ",org.elasticsearch.transport.TransportService:TRACE"
21+
)
1622
public void testIndicesSegmentsRestCancellation() throws Exception {
1723
runTest(new Request(HttpGet.METHOD_NAME, "/_segments"), IndicesSegmentsAction.NAME);
1824
}
1925

26+
@TestIssueLogging(
27+
issueUrl = "https://github.com/elastic/elasticsearch/issues/88201",
28+
value = "org.elasticsearch.http.BlockedSearcherRestCancellationTestCase:DEBUG"
29+
+ ",org.elasticsearch.transport.TransportService:TRACE"
30+
)
2031
public void testCatSegmentsRestCancellation() throws Exception {
2132
runTest(new Request(HttpGet.METHOD_NAME, "/_cat/segments"), IndicesSegmentsAction.NAME);
2233
}

0 commit comments

Comments
 (0)