diff --git a/changelogs/fragments/10816.yml b/changelogs/fragments/10816.yml new file mode 100644 index 000000000000..c6cf0fede368 --- /dev/null +++ b/changelogs/fragments/10816.yml @@ -0,0 +1,2 @@ +fix: +- [BUG] Fix careating index-patterns with ccs causes search threadPool to be exhausted ([#10816](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10816)) diff --git a/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.test.ts b/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.test.ts index eb9a43ed8215..3231af6a3bb6 100644 --- a/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.test.ts +++ b/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.test.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { getIndices, responseToItemArray, dedupeMatchedItems } from './get_indices'; +import { getIndices, responseToItemArray } from './get_indices'; import { httpServiceMock } from '../../../../../../core/public/mocks'; import { ResolveIndexResponseItemIndexAttrs, MatchedItem } from '../types'; import { Observable } from 'rxjs'; @@ -105,11 +105,10 @@ describe('getIndices', () => { }); expect(http.get).toHaveBeenCalled(); - expect(result.length).toBe(4); + expect(result.length).toBe(3); expect(result[0].name).toBe('f-alias'); expect(result[1].name).toBe('foo'); - expect(result[2].name).toBe('opensearch_dashboards_sample_data_ecommerce'); - expect(result[3].name).toBe('remoteCluster1:bar-01'); + expect(result[2].name).toBe('remoteCluster1:bar-01'); }); it('should ignore ccs query-all', async () => { @@ -160,12 +159,6 @@ describe('getIndices', () => { expect(responseToItemArray({}, getIndexTags)).toEqual([]); }); - it('matched items are deduped', () => { - const setA = [{ name: 'a' }, { name: 'b' }] as MatchedItem[]; - const setB = [{ name: 'b' }, { name: 'c' }] as MatchedItem[]; - expect(dedupeMatchedItems(setA, setB)).toHaveLength(3); - }); - describe('errors', () => { it('should handle errors gracefully', async () => { http.get.mockImplementationOnce(() => { diff --git a/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.ts b/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.ts index 0b4f5b3e8fd2..489775b490aa 100644 --- a/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.ts +++ b/src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.ts @@ -105,32 +105,6 @@ export const getIndicesViaResolve = async ({ }); }; -/** - * Takes two MatchedItem[]s and returns a merged set, with the second set prrioritized over the first based on name - * - * @param matchedA - * @param matchedB - */ - -export const dedupeMatchedItems = (matchedA: MatchedItem[], matchedB: MatchedItem[]) => { - const mergedMatchedItems = matchedA.reduce((col, item) => { - col[item.name] = item; - return col; - }, {} as Record); - - matchedB.reduce((col, item) => { - col[item.name] = item; - return col; - }, mergedMatchedItems); - - return Object.values(mergedMatchedItems).sort((a, b) => { - if (a.name > b.name) return 1; - if (b.name > a.name) return -1; - - return 0; - }); -}; - export async function getIndices({ http, getIndexTags = () => [], @@ -147,7 +121,6 @@ export async function getIndices({ dataSourceId?: string; }): Promise { const pattern = rawPattern.trim(); - const isCCS = pattern.indexOf(':') !== -1; const requests: Array> = []; // Searching for `*:` fails for CCS environments. The search request @@ -184,26 +157,8 @@ export async function getIndices({ }); requests.push(promiseResolve); - if (isCCS) { - // CCS supports ±1 major version. We won't be able to expect resolve endpoint to exist until v9 - const promiseSearch = getIndicesViaSearch({ - getIndexTags, - pattern, - searchClient, - showAllIndices, - dataSourceId, - }).catch(() => []); - requests.push(promiseSearch); - } - const responses = await Promise.all(requests); - - if (responses.length === 2) { - const [resolveResponse, searchResponse] = responses; - return dedupeMatchedItems(searchResponse, resolveResponse); - } else { - return responses[0]; - } + return responses[0]; } export const responseToItemArray = ( diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts index 0ebbb7539e42..95c0b2919beb 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/get_indices.ts @@ -209,18 +209,6 @@ export async function getIndices({ }); requests.push(promiseResolve); - if (isCCS) { - // CCS supports ±1 major version. We won't be able to expect resolve endpoint to exist until v9 - const promiseSearch = getIndicesViaSearch({ - getIndexTags, - pattern, - searchClient, - showAllIndices, - dataSourceId, - }).catch(() => []); - requests.push(promiseSearch); - } - const responses = await Promise.all(requests); if (responses.length === 2) {