mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [Add support for aborting in fetchTextBased (ESQL) (#168544)](https://github.com/elastic/kibana/pull/168544) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Lukas Olson","email":"lukas@elastic.co"},"sourceCommit":{"committedDate":"2023-10-13T06:09:10Z","message":"Add support for aborting in fetchTextBased (ESQL) (#168544)\n\n## Summary\r\n\r\nAdds support for aborting previous ESQL calls when a new one is issued.\r\n\r\nBefore:\r\n\r\n\r\n1af57552
-8974-4f6f-93af-cb01283b03da\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [ ] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### Risk Matrix\r\n\r\nDelete this section if it is not applicable to this PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other developers to\r\nidentify risks that should be tested prior to the change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider some of the following examples\r\nand how they may potentially impact the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| Multiple Spaces—unexpected behavior in non-default Kibana Space.\r\n| Low | High | Integration tests will verify that all features are still\r\nsupported in non-default Kibana Space and when user switches between\r\nspaces. |\r\n| Multiple nodes—Elasticsearch polling might have race conditions\r\nwhen multiple Kibana nodes are polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so executing them multiple times will not result\r\nin logical error, but will degrade performance. To test for this case we\r\nadd plenty of unit tests around this logic and document manual testing\r\nprocedure. |\r\n| Code should gracefully handle cases when feature X or plugin Y are\r\ndisabled. | Medium | High | Unit tests will verify that any feature flag\r\nor plugin combination still results in our service operational. |\r\n| [See more potential risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"77809650f1b72f181c757635c03274413371aec2","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","Team:Visualizations","release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.11.0","Feature:ES|QL","v8.12.0"],"number":168544,"url":"https://github.com/elastic/kibana/pull/168544","mergeCommit":{"message":"Add support for aborting in fetchTextBased (ESQL) (#168544)\n\n## Summary\r\n\r\nAdds support for aborting previous ESQL calls when a new one is issued.\r\n\r\nBefore:\r\n\r\n\r\n1af57552
-8974-4f6f-93af-cb01283b03da\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [ ] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### Risk Matrix\r\n\r\nDelete this section if it is not applicable to this PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other developers to\r\nidentify risks that should be tested prior to the change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider some of the following examples\r\nand how they may potentially impact the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| Multiple Spaces—unexpected behavior in non-default Kibana Space.\r\n| Low | High | Integration tests will verify that all features are still\r\nsupported in non-default Kibana Space and when user switches between\r\nspaces. |\r\n| Multiple nodes—Elasticsearch polling might have race conditions\r\nwhen multiple Kibana nodes are polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so executing them multiple times will not result\r\nin logical error, but will degrade performance. To test for this case we\r\nadd plenty of unit tests around this logic and document manual testing\r\nprocedure. |\r\n| Code should gracefully handle cases when feature X or plugin Y are\r\ndisabled. | Medium | High | Unit tests will verify that any feature flag\r\nor plugin combination still results in our service operational. |\r\n| [See more potential risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"77809650f1b72f181c757635c03274413371aec2"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168544","number":168544,"mergeCommit":{"message":"Add support for aborting in fetchTextBased (ESQL) (#168544)\n\n## Summary\r\n\r\nAdds support for aborting previous ESQL calls when a new one is issued.\r\n\r\nBefore:\r\n\r\n\r\n1af57552
-8974-4f6f-93af-cb01283b03da\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [ ] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### Risk Matrix\r\n\r\nDelete this section if it is not applicable to this PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other developers to\r\nidentify risks that should be tested prior to the change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider some of the following examples\r\nand how they may potentially impact the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| Multiple Spaces—unexpected behavior in non-default Kibana Space.\r\n| Low | High | Integration tests will verify that all features are still\r\nsupported in non-default Kibana Space and when user switches between\r\nspaces. |\r\n| Multiple nodes—Elasticsearch polling might have race conditions\r\nwhen multiple Kibana nodes are polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so executing them multiple times will not result\r\nin logical error, but will degrade performance. To test for this case we\r\nadd plenty of unit tests around this logic and document manual testing\r\nprocedure. |\r\n| Code should gracefully handle cases when feature X or plugin Y are\r\ndisabled. | Medium | High | Unit tests will verify that any feature flag\r\nor plugin combination still results in our service operational. |\r\n| [See more potential risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"77809650f1b72f181c757635c03274413371aec2"}}]}] BACKPORT--> Co-authored-by: Lukas Olson <lukas@elastic.co>
This commit is contained in:
parent
0029b8ea93
commit
885f469234
4 changed files with 46 additions and 2 deletions
|
@ -382,5 +382,33 @@ describe('test fetchAll', () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should swallow abort errors', async () => {
|
||||
const collect = subjectCollector(subjects.documents$);
|
||||
mockfetchTextBased.mockRejectedValue({ msg: 'The query was aborted' });
|
||||
const query = { esql: 'from foo' };
|
||||
deps = {
|
||||
abortController: new AbortController(),
|
||||
inspectorAdapters: { requests: new RequestAdapter() },
|
||||
searchSessionId: '123',
|
||||
initialFetchStatus: FetchStatus.UNINITIALIZED,
|
||||
useNewFieldsApi: true,
|
||||
savedSearch: savedSearchMock,
|
||||
services: discoverServiceMock,
|
||||
getAppState: () => ({ query }),
|
||||
getInternalState: () => ({
|
||||
dataView: undefined,
|
||||
savedDataViews: [],
|
||||
adHocDataViews: [],
|
||||
expandedDoc: undefined,
|
||||
customFilters: [],
|
||||
}),
|
||||
};
|
||||
fetchAll(subjects, false, deps);
|
||||
deps.abortController.abort();
|
||||
await waitForNextTick();
|
||||
|
||||
expect((await collect()).find(({ error }) => error)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -61,6 +61,7 @@ export function fetchAll(
|
|||
services,
|
||||
inspectorAdapters,
|
||||
savedSearch,
|
||||
abortController,
|
||||
} = fetchDeps;
|
||||
const { data } = services;
|
||||
const searchSource = savedSearch.searchSource.createChild();
|
||||
|
@ -93,7 +94,14 @@ export function fetchAll(
|
|||
// Start fetching all required requests
|
||||
const response =
|
||||
useTextbased && query
|
||||
? fetchTextBased(query, dataView, data, services.expressions, inspectorAdapters)
|
||||
? fetchTextBased(
|
||||
query,
|
||||
dataView,
|
||||
data,
|
||||
services.expressions,
|
||||
inspectorAdapters,
|
||||
abortController.signal
|
||||
)
|
||||
: fetchDocuments(searchSource, fetchDeps);
|
||||
const fetchType = useTextbased && query ? 'fetchTextBased' : 'fetchDocuments';
|
||||
const startTime = window.performance.now();
|
||||
|
@ -141,6 +149,10 @@ export function fetchAll(
|
|||
|
||||
checkHitCount(dataSubjects.main$, records.length);
|
||||
})
|
||||
// In the case that the request was aborted (e.g. a refresh), swallow the abort error
|
||||
.catch((e) => {
|
||||
if (!abortController.signal.aborted) throw e;
|
||||
})
|
||||
// Only the document query should send its errors to main$, to cause the full Discover app
|
||||
// to get into an error state. The other queries will not cause all of Discover to error out
|
||||
// but their errors will be shown in-place (e.g. of the chart).
|
||||
|
|
|
@ -30,6 +30,7 @@ export function fetchTextBased(
|
|||
data: DataPublicPluginStart,
|
||||
expressions: ExpressionsStart,
|
||||
inspectorAdapters: Adapters,
|
||||
abortSignal?: AbortSignal,
|
||||
filters?: Filter[],
|
||||
inputQuery?: Query
|
||||
): Promise<RecordsFetchResponse> {
|
||||
|
@ -43,9 +44,11 @@ export function fetchTextBased(
|
|||
})
|
||||
.then((ast) => {
|
||||
if (ast) {
|
||||
const execution = expressions.run(ast, null, {
|
||||
const contract = expressions.execute(ast, null, {
|
||||
inspectorAdapters,
|
||||
});
|
||||
abortSignal?.addEventListener('abort', contract.cancel);
|
||||
const execution = contract.getData();
|
||||
let finalData: DataTableRecord[] = [];
|
||||
let textBasedQueryColumns: Datatable['columns'] | undefined;
|
||||
let error: string | undefined;
|
||||
|
|
|
@ -332,6 +332,7 @@ export class SavedSearchEmbeddable
|
|||
this.services.data,
|
||||
this.services.expressions,
|
||||
this.services.inspector,
|
||||
this.abortController.signal,
|
||||
this.input.filters,
|
||||
this.input.query
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue