Skip to content

Commit

Permalink
[ML] Fix unit test deadlock problem (#34174)
Browse files Browse the repository at this point in the history
This change fixes a potential deadlock problem in the unit
test introduced in #34117.

It also removes a piece of debug code and corrects a docs
formatting problem that were both added in that same PR.
  • Loading branch information
droberts195 authored and kcm committed Oct 30, 2018
1 parent aeba58a commit 2d0ac06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/reference/ml/apis/find-file-structure.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ If the request does not encounter errors, you receive the following result:

If you try to analyze a lot of data then the analysis will take a long time.
If you want to limit the amount of processing your {es} cluster performs for
a request, use the timeout query parameter. The analysis will be aborted and
a request, use the `timeout` query parameter. The analysis will be aborted and
an error returned when the timeout expires. For example, you can replace 20000
lines in the previous example with 200000 and set a 1 second timeout on the
analysis:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ public void testFindFileStructureTimeout() throws IOException, InterruptedExcept
// Expected if timeout occurs and the input stream is closed before junk generation is complete
}
});
junkProducer.start();

try (InputStream bigInput = new PipedInputStream(generator)) {

junkProducer.start();

ElasticsearchTimeoutException e = expectThrows(ElasticsearchTimeoutException.class,
() -> structureFinderManager.findFileStructure(explanation, linesOfJunk - 1, bigInput, EMPTY_OVERRIDES, timeout));

assertThat(e.getMessage(), startsWith("Aborting structure analysis during ["));
assertThat(e.getMessage(), endsWith("] as it has taken longer than the timeout of [" + timeout + "]"));
explanation.add(e.getMessage());
}

// This shouldn't take anything like 10 seconds, but VMs can stall so it's best to
Expand Down

0 comments on commit 2d0ac06

Please sign in to comment.