Skip to content

[Entity Store] Keep per-process extraction state - #290481

Open
kubasobon wants to merge 8 commits into
mainfrom
entity-store/extraction-state
Open

[Entity Store] Keep per-process extraction state#290481
kubasobon wants to merge 8 commits into
mainfrom
entity-store/extraction-state

Conversation

@kubasobon

@kubasobon kubasobon commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Closes #288602. Stacked on entity-store/layered-config (#289855).

The entity store keeps one extraction cursor per engine under logExtractionState. When two
processes run against the same engine (#288601), they share that field and one process overwrites
the other's cursor — logs get skipped or reprocessed silently.

This adds a second, independent cursor field nonPriorityLogExtractionState (model version 9),
and routes each process to its own field based on extractionMode.

@kubasobon
kubasobon requested review from a team as code owners September 11, 2026 09:26
@kubasobon
kubasobon requested a review from opauloh September 11, 2026 09:26
@infra-vault-gh-plugin-prod

infra-vault-gh-plugin-prod Bot commented Sep 11, 2026

Copy link
Copy Markdown
🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@kubasobon kubasobon self-assigned this Sep 11, 2026
@kubasobon kubasobon added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Sep 11, 2026
@kubasobon kubasobon changed the title entity_store: per-process extraction state (#288602) [Entity Store] Store per-process extraction state Sep 11, 2026
@kubasobon kubasobon changed the title [Entity Store] Store per-process extraction state [Entity Store] Keep per-process extraction state Sep 11, 2026
@kubasobon
kubasobon added this pull request to stack #290482 September 11, 2026 09:30
@kubasobon
kubasobon force-pushed the entity-store/extraction-state branch from 3e68d5c to b81043b Compare September 11, 2026 09:43
@elastic-vault-github-plugin-prod
elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner September 11, 2026 10:52
@kibanamachine

Copy link
Copy Markdown
Contributor

Saved Objects CI check failed

1 issue(s) across 1 type(s).

entity-engine-descriptor-v2

  • [existing-type/too-many-new-model-versions] The SO type 'entity-engine-descriptor-v2' is defining 2 new model versions, but can only define one at a time. Fix: Split the change across multiple PRs so each one introduces a single new model version. (docs) (baseline serverless baseline)

Run locally

node scripts/check_saved_objects --baseline 384373226111f1aaf3369363ee97eedd803c3ac4

See the Saved Objects troubleshooting guide and the model versions documentation for details.

/** Returns the SO update patch for this extraction mode. Each mode writes to its own cursor field
* so the two processes do not overwrite each other's position. */
private cursorPatch(state: EngineLogExtractionState): Partial<EngineDescriptor> {
return this.extractionMode === 'nonPriority'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but might it be more explicit to map each mode to a state to show that single and priority share?

I am coming to this quite fresh but it took me a moment to figure out that this ternary means single and priority share a cursor field. Would this be overkill?

const CURSOR_FIELD = {
  single: 'logExtractionState',
  priority: 'logExtractionState',
  nonPriority: 'nonPriorityLogExtractionState',
} as const;

private cursorPatch(state: EngineLogExtractionState): Partial<EngineDescriptor> {
  return { [CURSOR_FIELD[this.extractionMode]]: state };
}

@@ -2026,3 +2033,122 @@ describe('LogsExtractionClient mid-slice resume', () => {
}
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth adding a test for when priority is the same bookmark as single. It should resume from logExtractionState and keep writing that field.

@hop-dev hop-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🚀

Base automatically changed from entity-store/layered-config to main September 12, 2026 08:08
@kubasobon
kubasobon force-pushed the entity-store/extraction-state branch from 30b8068 to b408d77 Compare September 12, 2026 08:08
@kibanamachine

kibanamachine commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

💔 Build Failed

Failed CI Steps

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [5f8193a]

History

cc @kubasobon

@chennn1990 chennn1990 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, great one
Please see my comments

});
expect(result).not.toHaveProperty('nonPriorityLogExtractionState');
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove that file, no need to test an already tested SO management


/** Maps each extraction mode to its cursor field. single and priority share logExtractionState;
* nonPriority has its own field so the two processes do not overwrite each other's position. */
private static readonly CURSOR_FIELD: Record<ExtractionMode, keyof EngineDescriptor> = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe CURSOR_FIELD is a bit specific, I would rename it to any constant indicate we aim to achieve the log extraction state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Entity Store] Dual-process: per-process extraction state (saved object migration)

4 participants