[Entity Store] Reset state error after successful task run#263087
[Entity Store] Reset state error after successful task run#263087orouz merged 3 commits intoelastic:mainfrom
Conversation
75c6123 to
2bb9a8b
Compare
| if (isRequestAbortedError(error)) { | ||
| this.logger.warn(`Logs extraction was aborted for entity type ${type}`); | ||
| return { success: false, error }; | ||
| } | ||
|
|
There was a problem hiding this comment.
This depends I believe. If it's a requested aborted and we have processed 0 pages, this warrants be called an error.
If one or more pages have been processed, we can ignore.
But I believe the issue should not be treated like this. I think we should clear the error if a successful run has happened. The timeout is the easy one to solve.
But what if there is a cluster upgrade and elasticsearch is unavailable for one or two iterations? Then we are able to resume on the third iteration and the error never gets cleaned.
I believe the best solution is: clear the error SO once we have successful run
There was a problem hiding this comment.
I believe the best solution is: clear the error SO once we have successful run
I tend to agree. In addition, I would persist also aborted requests and clear them after a successful run of the Kibana task.
f19cd5d to
7dac6af
Compare
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]
History
|
uri-weisman
left a comment
There was a problem hiding this comment.
Approved, even though we have a minor race condition.
Let's handle it in a follow-up PR.
| const current = await this.findOrThrow(entityType); | ||
| const updated = updater(current); | ||
| const id = this.getSavedObjectId(entityType); | ||
| const { attributes } = await this.soClient.update<EngineDescriptor>( |
There was a problem hiding this comment.
We have a potential race condition here, any concurrent change to the SO between findOrThrow() and update() can be lost (a call to the entity store management api updates the SO).
I consider it as minor, but something we should be aware of.
The right way to overcome this race would be by optimistic concurrency, adding the SO version to the update call, a conflict will be thrown in case there were an additional update between our read-write operation.
Example:
public async get(
id: string,
spaceId?: string
): Promise<{ id: string; attributes: RuleSavedObjectAttributes; version?: string }> {
const namespace = spaceIdToNamespace(this.spaces, spaceId);
const doc = await this.client.get<RuleSavedObjectAttributes>(
RULE_SAVED_OBJECT_TYPE,
id,
namespace ? { namespace } : undefined
);
return { id: doc.id, attributes: doc.attributes, version: doc.version };
} public async update({
id,
attrs,
version,
}: {
id: string;
attrs: RuleSavedObjectAttributes;
version?: string;
}): Promise<void> {
await this.client.update<RuleSavedObjectAttributes>(RULE_SAVED_OBJECT_TYPE, id, attrs, {
...(version ? { version } : {}),
mergeAttributes: false,
});
}There was a problem hiding this comment.
this is the same for our regular update not just the newly added updateWith
doc.version seems like a nice addition we should add anyway, even if this specifically is hardly an issue
|
Starting backport for target branches: 9.4 https://github.com/elastic/kibana/actions/runs/24628137448 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…3087) (#264284) # Backport This will backport the following commits from `main` to `9.4`: - [[Entity Store] Reset state error after successful task run (#263087)](#263087) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"orouz","email":"or.ouziel@elastic.co"},"sourceCommit":{"committedDate":"2026-04-19T11:35:34Z","message":"[Entity Store] Reset state error after successful task run (#263087)","sha":"b2a93965a2fe962dc6a625ee3a69a762e39bca5e","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","Entity Store (Next)","Team:Core Analysis","v9.4.0","v9.5.0"],"title":"[Entity Store] Reset state error after successful task run","number":263087,"url":"https://github.com/elastic/kibana/pull/263087","mergeCommit":{"message":"[Entity Store] Reset state error after successful task run (#263087)","sha":"b2a93965a2fe962dc6a625ee3a69a762e39bca5e"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/263087","number":263087,"mergeCommit":{"message":"[Entity Store] Reset state error after successful task run (#263087)","sha":"b2a93965a2fe962dc6a625ee3a69a762e39bca5e"}}]}] BACKPORT--> Co-authored-by: orouz <or.ouziel@elastic.co>
* main: (114 commits) Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (elastic#263334) init on install (elastic#263732) [One Workflow] fail-fast TaskRecovery for interrupted runs (elastic#261275) [Entity Store] Reset state error after successful task run (elastic#263087) [api-docs] 2026-04-19 Daily api_docs build (elastic#264280) [UII] Fix integration card row height calculation (elastic#264212) [scout] migrate FTR logstash api tests (elastic#262953) [StorageIndexAdapter] Set auto_expand_replicas to fix yellow health on single-node ES clusters (elastic#263096) [api-docs] 2026-04-18 Daily api_docs build (elastic#264260) [Scout] Update test config manifests (elastic#264257) [Security Solution][Detection Engine] enables AI rule creation feature flag (elastic#264036) [dashboards as code] only validate id on PUT route when creating new dashboard (elastic#264161) chore(NA): bump version to 9.5.0 (elastic#262165) skip failing test suite (elastic#263649) skip failing test suite (elastic#264236) [Discover] Convert remaining Enzyme tests to RTL (elastic#259676) auto-implement: Labels in model endpoints table of the model details flyout look misaligned (elastic#263770) [ci] Promote ES docker image after verification (elastic#263890) [Observability:Onboarding] Remove suppress global announcements that was breaking ensemble tests (elastic#264169) [Cases][AttachmentV2] Migrate persistable state part 2 - ML and AIOps charts (elastic#262597) ...
…lastic#263087)" This reverts commit b2a9396.
…lastic#263087)" This reverts commit b2a9396.
…lastic#263087)" This reverts commit b2a9396.
…lastic#263087)" This reverts commit b2a9396.
closes #261551
we were setting the error to
undefinedbut applying it usingmergeAttributes: truewhich meant existing fields will not be set toundefinedadded an
updateWith(current => ...)method which lets the caller update the state object manually withmergeAttributes: false