-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Improve migration perf #99773
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
Improve migration perf #99773
Changes from all commits
7d12de8
af0ab44
c393e54
7aec820
2f6a3ce
d927702
2b618f3
f467e5d
128fed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,7 +381,7 @@ export interface LegacyDeleteState extends LegacyBaseState { | |
| readonly controlState: 'LEGACY_DELETE'; | ||
| } | ||
|
|
||
| export type State = | ||
| export type State = Readonly< | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: It's not |
||
| | FatalState | ||
| | InitState | ||
| | DoneState | ||
|
|
@@ -411,7 +411,8 @@ export type State = | |
| | LegacySetWriteBlockState | ||
| | LegacyReindexState | ||
| | LegacyReindexWaitForTaskState | ||
| | LegacyDeleteState; | ||
| | LegacyDeleteState | ||
| >; | ||
|
|
||
| export type AllControlStates = State['controlState']; | ||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,7 @@ | |
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import semverSatisfies from 'semver/functions/satisfies'; | ||
| import Semver from 'semver'; | ||
| import { SavedObjectAttributes, SavedObjectReference } from '../../../core/types'; | ||
| import { DashboardContainerStateWithType, DashboardPanelState } from './types'; | ||
| import { EmbeddablePersistableStateService } from '../../embeddable/common/types'; | ||
|
|
@@ -24,7 +23,7 @@ export interface SavedObjectAttributesAndReferences { | |
| } | ||
|
|
||
| const isPre730Panel = (panel: Record<string, string>): boolean => { | ||
| return 'version' in panel ? semverSatisfies(panel.version, '<7.3') : true; | ||
| return 'version' in panel ? Semver.gt('7.3.0', panel.version) : true; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not surprising given that |
||
| }; | ||
|
|
||
| function dashboardAttributesToState( | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure our state workflow is pure enough for this to not have any side effect? (should be but still asking)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a red herring:
https://github.com/elastic/kibana/blob/master/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts#L50
We are risking that any step might call
stateP.logs.push(). So far, I found that we are using everywherestateP.logs = [...stateP.logs, {...}], so we should be fine...Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgayvallet I'm not quite sure
cloneDeepusage is justified here.Mutations made during
modelexecution will be returned from themodeland State will be cloned with mutations during the nextmodelcall.The only difference is the
OldStatemutation won't affectNewStateshape. But AFAIKSavedObjectMigrationFnis the only valid case for mutations and we already clone thedocduringmigrateAndConvertcall.kibana/src/core/server/saved_objects/migrations/core/document_migrator.ts
Line 245 in 2f6a3ce
I'm fine to roll back the change. In this case, we will pay the penalty of deep cloning all the SO several times. Plus additional work for GC.
@afharo Can
stateP.logs.pushbe called with the current implementation? I think so.stateP.logsis not an immutable array,Stateis not frozen object (not sure why, btw)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a quick look, I don't think either. Also we're supposed to have unit tests covering these things, so I think we're fine keeping the change.