diff --git a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client.test.ts b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client.test.ts index 2612c8778898b..b00517d259a48 100644 --- a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client.test.ts +++ b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client.test.ts @@ -64,7 +64,12 @@ describe('ui settings', () => { await uiSettings.setMany({ one: 'value' }); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { one: 'value' }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { one: 'value' }, + { refresh: false } + ); }); it('updates several values in one operation', async () => { @@ -72,10 +77,15 @@ describe('ui settings', () => { await uiSettings.setMany({ one: 'value', another: 'val' }); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { - one: 'value', - another: 'val', - }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { + one: 'value', + another: 'val', + }, + { refresh: false } + ); }); it('automatically creates the savedConfig if it is missing', async () => { @@ -159,9 +169,14 @@ describe('ui settings', () => { await uiSettings.set('one', 'value'); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { - one: 'value', - }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { + one: 'value', + }, + { refresh: false } + ); }); it('validates value if a schema presents', async () => { @@ -202,7 +217,12 @@ describe('ui settings', () => { await uiSettings.remove('one'); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { one: null }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { one: null }, + { refresh: false } + ); }); it('does not fail validation', async () => { @@ -246,7 +266,12 @@ describe('ui settings', () => { await uiSettings.removeMany(['one']); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { one: null }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { one: null }, + { refresh: false } + ); }); it('updates several values in one operation', async () => { @@ -254,11 +279,16 @@ describe('ui settings', () => { await uiSettings.removeMany(['one', 'two', 'three']); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { - one: null, - two: null, - three: null, - }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { + one: null, + two: null, + three: null, + }, + { refresh: false } + ); }); it('does not fail validation', async () => { diff --git a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client_common.ts b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client_common.ts index 992a851db99fd..d52644a0e8bfe 100644 --- a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client_common.ts +++ b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_client_common.ts @@ -129,7 +129,7 @@ export abstract class UiSettingsClientCommon extends BaseUiSettingsClient { autoCreateOrUpgradeIfMissing?: boolean; }) { try { - await this.savedObjectsClient.update(this.type, this.id, changes); + await this.savedObjectsClient.update(this.type, this.id, changes, { refresh: false }); } catch (error) { if (!SavedObjectsErrorHelpers.isNotFoundError(error) || !autoCreateOrUpgradeIfMissing) { throw error; diff --git a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_global_client.test.ts b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_global_client.test.ts index 2e4988f20c9df..56c3d53e2109f 100644 --- a/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_global_client.test.ts +++ b/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_global_client.test.ts @@ -86,9 +86,14 @@ describe('ui settings global client', () => { const { uiSettingsClient, savedObjectsClient } = setup(); await uiSettingsClient.set('settingA', 'cde'); expect(savedObjectsClient.update).toHaveBeenCalledTimes(1); - expect(savedObjectsClient.update).toHaveBeenCalledWith(TYPE, ID, { - settingA: 'cde', - }); + expect(savedObjectsClient.update).toHaveBeenCalledWith( + TYPE, + ID, + { + settingA: 'cde', + }, + { refresh: false } + ); }); }); diff --git a/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts b/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts index 63a80e673a487..9f74929aaf2cc 100644 --- a/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts +++ b/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts @@ -79,6 +79,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { }, { id: version, + refresh: false, } ); }); @@ -110,6 +111,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { }, { id: version, + refresh: false, } ); }); @@ -140,7 +142,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { defaultIndex: 'another-index', isDefaultIndexMigrated: true, }, - { id: version } + { id: version, refresh: false } ); }); @@ -282,6 +284,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { }, { id: version, + refresh: false, } ); }); @@ -313,6 +316,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { }, { id: version, + refresh: false, } ); }); diff --git a/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts b/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts index d6e0fffa05868..53ec0b78d3f89 100644 --- a/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts +++ b/packages/core/ui-settings/core-ui-settings-server-internal/src/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts @@ -63,7 +63,7 @@ export async function createOrUpgradeSavedConfig( try { // create the new SavedConfig - await savedObjectsClient.create(type, attributes, { id: version }); + await savedObjectsClient.create(type, attributes, { id: version, refresh: false }); } catch (error) { if (handleWriteErrors) { if (SavedObjectsErrorHelpers.isConflictError(error)) { diff --git a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts index 2f02b51be5501..2c23eec3ca2aa 100644 --- a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts +++ b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts @@ -26,6 +26,7 @@ export async function emptyKibanaIndexAction({ await cleanSavedObjectIndices({ client, stats, log }); await migrateSavedObjectIndices(kbnClient); + await client.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); ALL_SAVED_OBJECT_INDICES.forEach((indexPattern) => stats.createdIndex(indexPattern)); return stats.toJSON(); } diff --git a/src/core/server/integration_tests/ui_settings/doc_missing.ts b/src/core/server/integration_tests/ui_settings/doc_missing.ts index b31514d4d11c8..4e04b0ecbd149 100644 --- a/src/core/server/integration_tests/ui_settings/doc_missing.ts +++ b/src/core/server/integration_tests/ui_settings/doc_missing.ts @@ -13,6 +13,8 @@ export const docMissingSuite = (savedObjectsIndex: string) => () => { beforeEach(async () => { const { esClient } = getServices(); + await esClient.indices.refresh({ index: savedObjectsIndex }); + // delete all docs from kibana index to ensure savedConfig is not found await esClient.deleteByQuery({ index: savedObjectsIndex,