File tree Expand file tree Collapse file tree
x-pack/plugins/rule_registry/server/rule_data_client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,10 @@ export class RuleDataClient implements IRuleDataClient {
107107 const clusterClient = await this . getClusterClient ( ) ;
108108 let simulatedRollover : IndicesRolloverResponse ;
109109 try {
110+ // By simulating the rollover here first, we can easily retrieve the current write index name
111+ // and the prospective new write index name. These index names will be used to check if the new
112+ // write index would have any mapping differences from the current write index, and if so, we
113+ // trigger an actual rollover.
110114 ( { body : simulatedRollover } = await clusterClient . indices . rollover ( {
111115 alias,
112116 dry_run : true ,
@@ -143,6 +147,10 @@ export class RuleDataClient implements IRuleDataClient {
143147 const needRollover = this . indexNeedsRollover ( currentVersions , targetVersions ) ;
144148 if ( needRollover ) {
145149 try {
150+ // We specify the new_index name explicitly here to avoid races that would cause us to roll
151+ // the index multiple times. If another function rolls the index in between the simulated rollover
152+ // above and this rollover, then this rollover will fail with a resource_already_exists_exception - so
153+ // we catch and suppress that exception. Any other exceptions are rethrown.
146154 await clusterClient . indices . rollover ( {
147155 alias,
148156 new_index : simulatedRollover . new_index ,
You can’t perform that action at this time.
0 commit comments