Skip to content

Conversation

@matriv
Copy link
Contributor

@matriv matriv commented Jul 5, 2021

Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: #74381

Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: elastic#74381
@matriv matriv added >docs General docs changes v8.0.0 :Analytics/EQL EQL querying v7.14.1 labels Jul 5, 2021
@matriv matriv requested review from costin and jrodewig July 5, 2021 09:04
@elasticmachine elasticmachine added Team:Docs Meta label for docs team Team:QL (Deprecated) Meta label for query languages team labels Jul 5, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@matriv matriv added the v7.15.0 label Jul 5, 2021
@matriv matriv requested a review from astefan July 5, 2021 15:26
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Do you think it's worth adding some kind of introduction before the settings? Something around "EQL has a circuit breaker to prevent it using too much memory when running sequence queries.... etc"

@matriv matriv requested review from astefan and costin July 5, 2021 16:15
@matriv
Copy link
Contributor Author

matriv commented Jul 5, 2021

@costin @astefan Please take another look at the new paragraph added.

@matriv matriv changed the title EQL: Add documentation for the CircuitBreaker EQL: [Docs] Add documentation for the CircuitBreaker Jul 5, 2021
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left three suggestions.

implements the sequence matching. When large amounts of data need to be processed,
and/or a large amount of matched sequences is requested by the user (by setting the
<<eql-search-api-params-size, size>> query param), the memory occupied by those
structures could potentially exceed the available memory in the JVM. This would cause
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
structures could potentially exceed the available memory in the JVM. This would cause
structures could potentially exceed the available memory of the JVM. This would cause

Comment on lines 800 to 801
needs to keep some structures in memory which are needed by the algorithm which
implements the sequence matching. When large amounts of data need to be processed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which are needed by the algorithm which implements

Too many whiches?
How about

Suggested change
needs to keep some structures in memory which are needed by the algorithm which
implements the sequence matching. When large amounts of data need to be processed,
needs to keep some structures in memory that are needed by the algorithm implementing the sequence matching. When large amounts of data need to be processed,

Comment on lines 809 to 810
query, so instead of an `OutOfMemory` exception, a `org.elasticsearch.common.breaker.CircuitBreakingException`
is thrown, and a descriptive error message is returned to the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the circuit breaker doesn't do its job, it doesn't mean an OOM is thrown. How about the following message?

Suggested change
query, so instead of an `OutOfMemory` exception, a `org.elasticsearch.common.breaker.CircuitBreakingException`
is thrown, and a descriptive error message is returned to the user.
query. When the breaker is triggered, an `org.elasticsearch.common.breaker.CircuitBreakingException`
is thrown and a descriptive error message is returned to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm torn between an org...... and a ...CircuitBreakingException :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving out the package name or even Exception (which are developers facing implementation details) is preferred. Just an "error message" or similar is enough. Not all users are developers.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

(<<static-cluster-setting,Static>>) The underlying type of the circuit breaker.
There are two valid options: `noop` and `memory`. `noop` means the circuit
breaker does nothing to prevent too much memory usage. `memory` means the
circuit breaker tracks the memory used by trained models and can potentially
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'used by trained models' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, thx! copy-paste error :(

[[eql-circuit-breaker]]
=== EQL circuit breaker settings

When a <<eql-sequences, sequence>> query is executed, the node handling the query,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last , looks misplaced.

Copy link
Contributor

@jrodewig jrodewig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I left some non-blocking suggestions that you can ignore if wanted.

Comment on lines +799 to +810
When a <<eql-sequences, sequence>> query is executed, the node handling the query
needs to keep some structures in memory, which are needed by the algorithm
implementing the sequence matching. When large amounts of data need to be processed,
and/or a large amount of matched sequences is requested by the user (by setting the
<<eql-search-api-params-size, size>> query param), the memory occupied by those
structures could potentially exceed the available memory of the JVM. This would cause
an `OutOfMemory` exception which would bring down the node.

To prevent this from happening, a special <<circuit-breaker, circuit breaker>> is used,
which limits the memory allocation during the execution of a <<eql-sequences, sequence>>
query. When the breaker is triggered, an `org.elasticsearch.common.breaker.CircuitBreakingException`
is thrown and a descriptive error message is returned to the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copy is good, but I wonder if we're over-explaining a bit. I'd consider shortening it:

Suggested change
When a <<eql-sequences, sequence>> query is executed, the node handling the query
needs to keep some structures in memory, which are needed by the algorithm
implementing the sequence matching. When large amounts of data need to be processed,
and/or a large amount of matched sequences is requested by the user (by setting the
<<eql-search-api-params-size, size>> query param), the memory occupied by those
structures could potentially exceed the available memory of the JVM. This would cause
an `OutOfMemory` exception which would bring down the node.
To prevent this from happening, a special <<circuit-breaker, circuit breaker>> is used,
which limits the memory allocation during the execution of a <<eql-sequences, sequence>>
query. When the breaker is triggered, an `org.elasticsearch.common.breaker.CircuitBreakingException`
is thrown and a descriptive error message is returned to the user.
The EQL circuit breaker limits the amount of memory that sequence queries can
use. The breaker prevents an OutOfMemoryError for queries with a large
<<eql-search-api-params-size,`size`>> or data set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@costin What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it as is. It didn't strike me as too verbose or too detailed. If the overall style of EQL documentation or that of the circuit breakers in Elasticsearch is more concise/trimmed down, then go with @jrodewig suggestion. Otherwise, my personal opinion is to leave it as is. Circuit breakers are a tricky subject in general imo since the memory calculation algorithm is rather non-obvious to the regular user. Enough information passed on in the docs helps sometimes clearing out the confusion around them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @astefan wrote.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

matriv and others added 2 commits July 6, 2021 22:18
Co-authored-by: James Rodewig <[email protected]>
Co-authored-by: James Rodewig <[email protected]>
@matriv matriv added the auto-backport Automatically create backport pull requests when merged label Jul 7, 2021
@matriv matriv merged commit dd302dc into elastic:master Jul 7, 2021
@matriv matriv deleted the eql-cb-docs branch July 7, 2021 07:20
elasticsearchmachine pushed a commit to elasticsearchmachine/elasticsearch that referenced this pull request Jul 7, 2021
Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: elastic#74381
elasticsearchmachine pushed a commit to elasticsearchmachine/elasticsearch that referenced this pull request Jul 7, 2021
Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: elastic#74381
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
7.14
7.x

elasticsearchmachine added a commit that referenced this pull request Jul 7, 2021
Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: #74381

Co-authored-by: Marios Trivyzas <[email protected]>
elasticsearchmachine added a commit that referenced this pull request Jul 7, 2021
Add documentation for the newly introduced CircuitBreaker, which is
used to restrict the memory usage for an EQL sequence query to avoid
OutOfMemory exceptions.

Follows: #74381

Co-authored-by: Marios Trivyzas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/EQL EQL querying auto-backport Automatically create backport pull requests when merged >docs General docs changes Team:Docs Meta label for docs team Team:QL (Deprecated) Meta label for query languages team v7.14.0 v7.15.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants