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 source] remove is_partial check #164506

Merged
merged 46 commits into from
Oct 2, 2023
Merged

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Aug 22, 2023

Closes #164893

Background

"is partial" has 2 meanings

  1. Results are incomplete because search is still running
  2. Search is finished. Results are incomplete because there are shard failures (either in local or remote clusters)

async search defines 2 flags.

  1. is_running: Whether the search is still being executed or it has completed
  2. is_partial: When the query is no longer running, indicates whether the search failed or was successfully completed on all shards. While the query is being executed, is_partial is always set to true
    note: there is a bug in async search where requests to only local clusters return is_partial:false when there are shard errors on the local cluster. See async search returns is_partial:false when local cluster has shard errors elasticsearch#98725. This should be resolved in 8.11

Kibana's existing search implementation does not align with Elasticsearch's is_running and is_partial flags. Kibana defines "is partial" as definition "1)". Elasticsearch async search defines "is partial" as definition "2)".

This PR aligns Kibana's usage of "is partial" with Elasticsearch's definition. This required the following changes

  1. isErrorResponse renamed to isAbortedResponse. Method no longer returns true when !response.isRunning && !!response.isPartial. Kibana handles results with incomplete data. Note removed export of isErrorResponse from data plugin since its use outside of data plugin does not make sense.
  2. Replace isPartialResponse with isRunningResponse. This aligns Kibana's definition with Elasticsearch async search flags.
  3. Remove isCompleteResponse. The word "complete" is ambiguous. Does it mean the search is finished (no longer running)? Or does it mean the search has all results and there are no shard failures?

@nreese
Copy link
Contributor Author

nreese commented Aug 23, 2023

@elasticmachine merge upstream

@nreese
Copy link
Contributor Author

nreese commented Aug 23, 2023

@elasticmachine merge upstream

@nreese
Copy link
Contributor Author

nreese commented Aug 25, 2023

@elasticmachine merge upstream

nreese added a commit that referenced this pull request Aug 28, 2023
`data.search` uses
[poll_search](https://github.com/elastic/kibana/blob/main/src/plugins/data/common/search/poll_search.ts)
to fetch data. `poll_search` checks for `isErrorResponse` and throws
when`isErrorResponse` is true. **Note** `searchSource.search` uses
`data.search` to perform searches.

```javascript
   return from(search()).pipe(
      expand(() => {
        const elapsedTime = Date.now() - startTime;
        return timer(getPollInterval(elapsedTime)).pipe(switchMap(search));
      }),
      tap((response) => {
        if (isErrorResponse(response)) {
          throw response ? new Error('Received partial response') : new AbortError();
        }
      }),
      takeWhile<Response>(isPartialResponse, true),
      takeUntil<Response>(aborted$)
    );
```

Subscribers to `data.search` and `searchSource.search` do not need to
check for `isErrorResponse` in `next`. `poll_search` has already thrown
then the response is `isErrorResponse` so these checks are dead code
blocks that are never executed.

This PR removes these dead code blocks. Breaking this change out of
#164506 so that it can be reviewed
in isolated.

---------

Co-authored-by: kibanamachine <[email protected]>
@nreese nreese added release_note:skip Skip the PR/issue when compiling release notes v8.11.0 Feature:Search Querying infrastructure in Kibana Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. labels Sep 26, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Member

@sphilipse sphilipse left a comment

Choose a reason for hiding this comment

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

ent-search changes LGTM

@botelastic botelastic bot added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Sep 27, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@nreese
Copy link
Contributor Author

nreese commented Sep 27, 2023

@elasticmachine merge upstream

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

AIOps changes LGTM

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Added a couple of minor comments below, overall LGTM!

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

The Visualizations team review was asked due to co-ownership with the discovery team. Lukas approval will be enough to allow merging as all changes are search related and the discovery team owns them 👍

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

LGTM for the Protections Experience and the Threat Hunting Investigations teams!

@nreese
Copy link
Contributor Author

nreese commented Oct 2, 2023

@elasticmachine merge upstream

@nreese
Copy link
Contributor Author

nreese commented Oct 2, 2023

@elasticmachine merge upstream

@patrykkopycinski patrykkopycinski added the ci:skip-cypress-osquery Skips osquery cypress checks label Oct 2, 2023
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Defend Workflows Cypress Tests #4 / Artifact pages Trusted applications should update Endpoint Policy on Endpoint when adding Trusted application name should update Endpoint Policy on Endpoint when adding Trusted application name
  • [job] [logs] FTR Configs #53 / copy to space with security copy to spaces user with no access from the default space single-namespace types "before each" hook for "should return 403 when copying to space with conflicts when overwriting"
  • [job] [logs] Security Solution Cypress Tests #9 / Ransomware Detection Alerts Ransomware in Timelines Renders ransomware entries in timelines table Renders ransomware entries in timelines table

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
data 2553 2549 -4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiops 595.8KB 595.8KB -3.0B
securitySolution 13.0MB 13.0MB -93.0B
synthetics 861.1KB 861.1KB -33.0B
threatIntelligence 56.5KB 56.5KB -1.0B
ux 166.0KB 166.0KB -1.0B
total -131.0B

Page load bundle

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

id before after diff
data 407.9KB 407.4KB -510.0B
observabilityShared 47.0KB 47.0KB -33.0B
total -543.0B
Unknown metric groups

API count

id before after diff
data 3288 3282 -6

History

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

@nreese nreese merged commit b5bcf69 into elastic:main Oct 2, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:skip-cypress-osquery Skips osquery cypress checks Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v8.11.0
Projects
None yet