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

[8.x] Apply task manager backpressure whenever a 500 error is returned in the task store (#198418) #198531

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

…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)
@kibanamachine kibanamachine merged commit cf0ab00 into elastic:8.x Oct 31, 2024
34 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @mikecote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants