-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Apply task manager backpressure whenever a 500 error is returned in the task store #198418
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mikecote
added
Feature:Task Manager
Team:ResponseOps
Label for the ResponseOps team (formerly the Cases and Alerting teams)
labels
Oct 30, 2024
💚 Build Succeeded
Metrics [docs]
cc @mikecote |
Pinging @elastic/response-ops (Team:ResponseOps) |
mikecote
added
release_note:skip
Skip the PR/issue when compiling release notes
v9.0.0
v8.17.0
backport:prev-minor
Backport to (8.x) the previous minor version (i.e. one version back from main)
labels
Oct 31, 2024
ymao1
approved these changes
Oct 31, 2024
Starting backport for target branches: 8.x |
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Oct 31, 2024
…he task store (elastic#198418) In this PR, I'm making the task manager apply backpressure whenever a 500 error is returned in the task store (msearch or other SO I/O). ## To verify 1. Apply the following diff, run Kibana and notice logs about poll interval and capacity configuration changing ``` diff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts index 2b3440e87c0..d2ffaa2f50f 100644 --- a/x-pack/plugins/task_manager/server/task_store.ts +++ b/x-pack/plugins/task_manager/server/task_store.ts @@ -574,6 +574,8 @@ export class TaskStore { const versionMap = this.createVersionMap([]); let allTasks = new Array<ConcreteTaskInstance>(); + responses[0].status = 500; + for (const response of responses) { if (response.status !== 200) { const err = new MsearchError(response.status); ``` 2. Undo previous changes, apply the following diff, run Kibana and notice logs about poll interval and capacity configuration changing ``` diff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts index 2b3440e87c0..95d14152e1d 100644 --- a/x-pack/plugins/task_manager/server/task_store.ts +++ b/x-pack/plugins/task_manager/server/task_store.ts @@ -12,6 +12,7 @@ import murmurhash from 'murmurhash'; import { v4 } from 'uuid'; import { Subject } from 'rxjs'; import { omit, defaults, get } from 'lodash'; +import { SavedObjectsErrorHelpers } from '@kbn/core/server'; import { SavedObjectError } from '@kbn/core-saved-objects-common'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; @@ -474,6 +475,7 @@ export class TaskStore { public async bulkGet(ids: string[]): Promise<BulkGetResult> { let result; try { + throw SavedObjectsErrorHelpers.decorateGeneralError(new Error('foo')); result = await this.savedObjectsRepository.bulkGet<SerializedConcreteTaskInstance>( ids.map((id) => ({ type: 'task', id })) ); ``` (cherry picked from commit 424233e)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
kibanamachine
added a commit
that referenced
this pull request
Oct 31, 2024
…d in the task store (#198418) (#198531) # Backport This will backport the following commits from `main` to `8.x`: - [Apply task manager backpressure whenever a 500 error is returned in the task store (#198418)](#198418) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Mike Côté","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-31T13:34:42Z","message":"Apply task manager backpressure whenever a 500 error is returned in the task store (#198418)\n\nIn this PR, I'm making the task manager apply backpressure whenever a\r\n500 error is returned in the task store (msearch or other SO I/O).\r\n\r\n## To verify\r\n1. Apply the following diff, run Kibana and notice logs about poll\r\ninterval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..d2ffaa2f50f 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -574,6 +574,8 @@ export class TaskStore {\r\n const versionMap = this.createVersionMap([]);\r\n let allTasks = new Array<ConcreteTaskInstance>();\r\n\r\n+ responses[0].status = 500;\r\n+\r\n for (const response of responses) {\r\n if (response.status !== 200) {\r\n const err = new MsearchError(response.status);\r\n```\r\n2. Undo previous changes, apply the following diff, run Kibana and\r\nnotice logs about poll interval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..95d14152e1d 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -12,6 +12,7 @@ import murmurhash from 'murmurhash';\r\n import { v4 } from 'uuid';\r\n import { Subject } from 'rxjs';\r\n import { omit, defaults, get } from 'lodash';\r\n+import { SavedObjectsErrorHelpers } from '@kbn/core/server';\r\n import { SavedObjectError } from '@kbn/core-saved-objects-common';\r\n\r\n import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';\r\n@@ -474,6 +475,7 @@ export class TaskStore {\r\n public async bulkGet(ids: string[]): Promise<BulkGetResult> {\r\n let result;\r\n try {\r\n+ throw SavedObjectsErrorHelpers.decorateGeneralError(new Error('foo'));\r\n result = await this.savedObjectsRepository.bulkGet<SerializedConcreteTaskInstance>(\r\n ids.map((id) => ({ type: 'task', id }))\r\n );\r\n```","sha":"424233e02645c5aecc4e03b01c2bd34377a96f4d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Task Manager","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.17.0"],"title":"Apply task manager backpressure whenever a 500 error is returned in the task store","number":198418,"url":"https://github.com/elastic/kibana/pull/198418","mergeCommit":{"message":"Apply task manager backpressure whenever a 500 error is returned in the task store (#198418)\n\nIn this PR, I'm making the task manager apply backpressure whenever a\r\n500 error is returned in the task store (msearch or other SO I/O).\r\n\r\n## To verify\r\n1. Apply the following diff, run Kibana and notice logs about poll\r\ninterval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..d2ffaa2f50f 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -574,6 +574,8 @@ export class TaskStore {\r\n const versionMap = this.createVersionMap([]);\r\n let allTasks = new Array<ConcreteTaskInstance>();\r\n\r\n+ responses[0].status = 500;\r\n+\r\n for (const response of responses) {\r\n if (response.status !== 200) {\r\n const err = new MsearchError(response.status);\r\n```\r\n2. Undo previous changes, apply the following diff, run Kibana and\r\nnotice logs about poll interval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..95d14152e1d 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -12,6 +12,7 @@ import murmurhash from 'murmurhash';\r\n import { v4 } from 'uuid';\r\n import { Subject } from 'rxjs';\r\n import { omit, defaults, get } from 'lodash';\r\n+import { SavedObjectsErrorHelpers } from '@kbn/core/server';\r\n import { SavedObjectError } from '@kbn/core-saved-objects-common';\r\n\r\n import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';\r\n@@ -474,6 +475,7 @@ export class TaskStore {\r\n public async bulkGet(ids: string[]): Promise<BulkGetResult> {\r\n let result;\r\n try {\r\n+ throw SavedObjectsErrorHelpers.decorateGeneralError(new Error('foo'));\r\n result = await this.savedObjectsRepository.bulkGet<SerializedConcreteTaskInstance>(\r\n ids.map((id) => ({ type: 'task', id }))\r\n );\r\n```","sha":"424233e02645c5aecc4e03b01c2bd34377a96f4d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198418","number":198418,"mergeCommit":{"message":"Apply task manager backpressure whenever a 500 error is returned in the task store (#198418)\n\nIn this PR, I'm making the task manager apply backpressure whenever a\r\n500 error is returned in the task store (msearch or other SO I/O).\r\n\r\n## To verify\r\n1. Apply the following diff, run Kibana and notice logs about poll\r\ninterval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..d2ffaa2f50f 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -574,6 +574,8 @@ export class TaskStore {\r\n const versionMap = this.createVersionMap([]);\r\n let allTasks = new Array<ConcreteTaskInstance>();\r\n\r\n+ responses[0].status = 500;\r\n+\r\n for (const response of responses) {\r\n if (response.status !== 200) {\r\n const err = new MsearchError(response.status);\r\n```\r\n2. Undo previous changes, apply the following diff, run Kibana and\r\nnotice logs about poll interval and capacity configuration changing\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts\r\nindex 2b3440e87c0..95d14152e1d 100644\r\n--- a/x-pack/plugins/task_manager/server/task_store.ts\r\n+++ b/x-pack/plugins/task_manager/server/task_store.ts\r\n@@ -12,6 +12,7 @@ import murmurhash from 'murmurhash';\r\n import { v4 } from 'uuid';\r\n import { Subject } from 'rxjs';\r\n import { omit, defaults, get } from 'lodash';\r\n+import { SavedObjectsErrorHelpers } from '@kbn/core/server';\r\n import { SavedObjectError } from '@kbn/core-saved-objects-common';\r\n\r\n import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';\r\n@@ -474,6 +475,7 @@ export class TaskStore {\r\n public async bulkGet(ids: string[]): Promise<BulkGetResult> {\r\n let result;\r\n try {\r\n+ throw SavedObjectsErrorHelpers.decorateGeneralError(new Error('foo'));\r\n result = await this.savedObjectsRepository.bulkGet<SerializedConcreteTaskInstance>(\r\n ids.map((id) => ({ type: 'task', id }))\r\n );\r\n```","sha":"424233e02645c5aecc4e03b01c2bd34377a96f4d"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Mike Côté <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport:prev-minor
Backport to (8.x) the previous minor version (i.e. one version back from main)
Feature:Task Manager
release_note:skip
Skip the PR/issue when compiling release notes
Team:ResponseOps
Label for the ResponseOps team (formerly the Cases and Alerting teams)
v8.17.0
v9.0.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, I'm making the task manager apply backpressure whenever a 500 error is returned in the task store (msearch or other SO I/O).
To verify