[Entity Store] Keep per-process extraction state - #290481
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
3e68d5c to
b81043b
Compare
Saved Objects CI check failed1 issue(s) across 1 type(s).
|
| /** 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' |
There was a problem hiding this comment.
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', () => { | |||
| } | |||
| ); | |||
| }); | |||
There was a problem hiding this comment.
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.
30b8068 to
b408d77
Compare
💔 Build Failed
Failed CI StepsMetrics [docs]
History
cc @kubasobon |
chennn1990
left a comment
There was a problem hiding this comment.
Thank you, great one
Please see my comments
| }); | ||
| expect(result).not.toHaveProperty('nonPriorityLogExtractionState'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
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> = { |
There was a problem hiding this comment.
Maybe CURSOR_FIELD is a bit specific, I would rename it to any constant indicate we aim to achieve the log extraction state.
Summary
Closes #288602. Stacked on
entity-store/layered-config(#289855).The entity store keeps one extraction cursor per engine under
logExtractionState. When twoprocesses 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.