Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search Sessions] fix saved object can be created even if courier:batchSearches is enabled #105407

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Jul 13, 2021

Summary

This pr fixes #104311: the issue is when courier:batchSearches enabled (which essentially switches all searches that go through the searchSource from async to sync search), we still treat those as they are async from a search session perspective.

There are a lot of ways how to handle this, but since this fix is focused on courier:batchSearches, I suggest we contain the fix together with the option usage.

Considerations

Dashboard with different panels

With this option enabled you can have a dashboard that uses both async search and sync search, because courier:batchSearches is applied on SearchSource level and, for example, tsvb doesn't use it.

In this case, only async searches will use sessionId and only those will get into the session object.

Using search strategy that doesn't support search session

You can still use search service as follows:

search({strategy: 'es', sessionId: 'id'}) 

this is incorrect usage because es search strategy doesn't support sessions, but it will still create all the session overhead.

@lizozom, @lukasolson, Should I create an issue to improve this?

Checklist

Risk Matrix

Fix is very contained. Change is applied only when courier:batchSearches is used.

For maintainers

@@ -287,6 +287,8 @@ export class SearchSource {
// This still uses bfetch for batching.
if (!options?.strategy && syncSearchByDefault) {
options.strategy = ES_SEARCH_STRATEGY;
// `ES_SEARCH_STRATEGY` doesn't support search sessions, hence remove sessionId
options.sessionId = undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a lot of ways how to handle this, but since this fix is focused on courier:batchSearches, I suggest we contain the fix together with the option usage.

Long term, I think we find a how-to avoid search session overhead (both on UI and server) when running a search strategy that doesn't support search sessions. (see pr description for more details)

Copy link
Contributor

@lizozom lizozom Jul 13, 2021

Choose a reason for hiding this comment

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

Won't this disable client side caching of responses as well 🤔 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes @lizozom!

But otherwise not sure how to solve it also keeping the fix surface as small as possible:

We want cache to still work, so we need to pass sessionId,
but then we also don't want to trackSearch in client-side session service and ideally don't want to pass sessionId to the server.

I don't think we should put such conditional logic that depends on a specific strategy into client-side search interceptor, hence I suggest going with removing sessionId in searchSource level

@Dosant Dosant marked this pull request as ready for review July 13, 2021 13:29
@Dosant Dosant requested a review from a team as a code owner July 13, 2021 13:29
@Dosant Dosant added bug Fixes for quality problems that affect the customer experience Feature:Search Querying infrastructure in Kibana v7.14.0 Team:AppServices labels Jul 13, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@Dosant Dosant added release_note:fix impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. labels Jul 13, 2021
Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

I tested this change and if I go to discover, the search goes out using es strategy but I still see the indicator and I can still save the session.

image

image

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Nothing like a good old kbn clean

Would be nice to have a functional test for this as well :-)

@Dosant
Copy link
Contributor Author

Dosant commented Jul 15, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 839.9KB 840.0KB +25.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Jul 15, 2021

Would be nice to have a functional test for this as well :-)

Discussed offline. Intentionally, adding only a unit test because the fix is very contained and only for a deprecated option we plan to remove soon

@Dosant Dosant added the auto-backport Deprecated - use backport:version if exact versions are needed label Jul 15, 2021
@Dosant Dosant merged commit 4b4a405 into elastic:master Jul 15, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 15, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.14

This backport PR will be merged automatically after passing CI.

@Dosant Dosant added v7.15.0 v8.0.0 auto-backport Deprecated - use backport:version if exact versions are needed and removed auto-backport Deprecated - use backport:version if exact versions are needed labels Jul 15, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 15, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

jloleysens added a commit to jloleysens/kibana that referenced this pull request Jul 15, 2021
…-png-pdf-report-type

* 'master' of github.com:elastic/kibana: (75 commits)
  [Search Sessions] Don’t try to delete errored searches (elastic#105434)
  [Search Sessions] fix saved object can be created even if courier:batchSearches is enabled (elastic#105407)
  [Remote Clusters] Fixed remote clusters details flyout for long strings (elastic#105592)
  [ML] Functional tests - re-activate a11y tests (elastic#105198)
  [APM] Typed client-side routing (elastic#104274)
  [Canvas] Expression error (elastic#103048)
  [ML] Fixing job wizard with missing description (elastic#105574)
  [Security Solution][Alerts] - Add alerts subfeature UI (elastic#105505)
  Upgrade EUI to v35.0.0 (elastic#105127)
  [Reporting] Clean up types for internal APIs needed for UI (elastic#105508)
  skip flaky suite (elastic#105087)
  [Workplace Search] Fix Chrome issues with GitHub sources (elastic#105680)
  [Fleet] Add containerized fleet server instructions to Fleet README (elastic#105669)
  [ML] Add api integration test for analytics map endpoint  (elastic#105531)
  Fixes cypress flake across two tests (elastic#105645)
  [Logs&Metrics UI] add owner properties to plugin manifest (elastic#105580)
  chore(NA): introduce preset for jest-integration tests on @kbn/test (elastic#105144)
  [Enterprise Search] Added Thumbnails to Search UI (elastic#104199)
  Translate App Search credentials list (elastic#105619)
  [APM] APM agent config created prior to Fleet migration is not injected into integration policy (elastic#105504)
  ...

# Conflicts:
#	x-pack/plugins/reporting/common/types.ts
#	x-pack/plugins/reporting/public/management/report_listing.test.tsx
kibanamachine added a commit that referenced this pull request Jul 15, 2021
…chSearches is enabled (#105407) (#105733)

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
kibanamachine added a commit that referenced this pull request Jul 15, 2021
…chSearches is enabled (#105407) (#105738)

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience Feature:Search Querying infrastructure in Kibana impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. release_note:fix v7.14.0 v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Search Sessions] Saved object can be created even if courier:batchSearches is enabled
4 participants