Skip to content

Conversation

original-brownbear
Copy link
Contributor

Making this work with batched execution and fixing a memory leak:

  • Fix memory leak by removing listener on first message. There really only is a single message here per node anyway with batched execution in the mix. Either it's a single shard on the data node and we get a single query message or it's multiple shards and we get a single batched message, so fine to remove listener after the first message since all tests do a single request only anyway.
  • Add a new hook that allows inspection of the actual response. This is needed for batched since batched sends a non-error response even if the data node failed all searches. We had this before in the onResponseSent hook but checking the instance after it's been sent over the wire causes needless overhead in the production code so moving to a "before-style" hook here.

part of #125788

Making this work with batched execution and fixing a memory leak:

* Fix memory leak by removing listener on first message. There really only is a single message
here per node anyway with batched execution in the mix. Either it's a single shard on the data node
and we get a single query message or it's multiple shards and we get a single batched message,
so fine to remove listener after the first message since all tests do a single request only anyway.
* Add a new hook that allows inspection of the actual response. This is needed for batched since batched
sends a non-error response even if the data node failed all searches. We had this before in the
`onResponseSent` hook but checking the instance after it's been sent over the wire causes needless
overhead in the production code so moving to a "before-style" hook here.
@original-brownbear original-brownbear added >test Issues or PRs that are addressing/adding tests :Search Foundations/Search Catch all for Search Foundations labels Apr 22, 2025
@elasticsearchmachine elasticsearchmachine added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.1.0 labels Apr 22, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

* @param action the request action
* @param response response instance
*/
default void onBeforeResponseSent(long requestId, String action, TransportResponse response) {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaveCTurner wdyt? this should be ok right? In prod the overhead is negligible I think.

Copy link
Contributor

@benchaplin benchaplin left a comment

Choose a reason for hiding this comment

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

I left one comment below. I have a general question as well—what do you mean:

We had this before in the onResponseSent hook

I was a bit surprised that we don't have testing to inspect transport responses being sent from data nodes.

@original-brownbear
Copy link
Contributor Author

We had this before in the onResponseSent hook

#125163 see this PR, we were wasting memory holding on to the message just for the noop (in production) hook :) I dropped the holding on to the message till after it's fully flushed to the wire in that PR.

@benchaplin
Copy link
Contributor

@DaveCTurner I'm looking to merge this but am still curious what you think about this additional method call in OutboundHandler (as Armin previously asked). I don't have a good feel for how performance-sensitive we are at that layer...

@DaveCTurner
Copy link
Contributor

I don't have a good feel for how performance-sensitive we are at that layer...

Pretty performance-sensitive but I think we can tolerate this change.

@benchaplin
Copy link
Contributor

@elasticmachine test this please

1 similar comment
@drempapis
Copy link
Contributor

@elasticmachine test this please

@benchaplin
Copy link
Contributor

@elasticmachine run elasticsearch-ci

@benchaplin benchaplin closed this Jul 30, 2025
@benchaplin benchaplin reopened this Jul 30, 2025
@benchaplin benchaplin assigned benchaplin and unassigned benchaplin Jul 30, 2025
@drempapis
Copy link
Contributor

@elasticmachine run elasticsearch-ci

@drempapis drempapis self-assigned this Jul 30, 2025
@drempapis
Copy link
Contributor

@elasticmachine run elasticsearch-ci

@drempapis
Copy link
Contributor

@elasticmachine run Elasticsearch Serverless Checks

@drempapis
Copy link
Contributor

@elasticmachine run Elasticsearch Serverless Checks
@elasticmachine run elasticsearch-ci

@drempapis
Copy link
Contributor

@elasticmachine run Elasticsearch Serverless Checks
@elasticmachine run elasticsearch-ci

@benchaplin
Copy link
Contributor

Forked: #132227

@benchaplin benchaplin closed this Jul 31, 2025
@javanna javanna removed the v9.2.0 label Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch >test Issues or PRs that are addressing/adding tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants