**Build scan:**
https://gradle-enterprise.elastic.co/s/5j3jpwqvko5gk/tests/:x-pack:plugin:ml:qa:native-multi-node-tests:javaRestTest/org.elasticsearch.xpack.ml.integration.ScheduledEventsIT/testScheduledEvents

**Reproduction line:**
```
./gradlew ':x-pack:plugin:ml:qa:native-multi-node-tests:javaRestTest' --tests "org.elasticsearch.xpack.ml.integration.ScheduledEventsIT.testScheduledEvents" -Dtests.seed=998D58FCF337DF3E -Dtests.locale=es-UY -Dtests.timezone=Pacific/Pago_Pago -Druntime.java=17
```

**Applicable branches:**
8.7

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.ml.integration.ScheduledEventsIT&tests.test=testScheduledEvents

**Failure excerpt:**
```
org.elasticsearch.action.FailedNodeException: Failed node [gVGASryzSyqAVfaLDbeGXw]

  at __randomizedtesting.SeedInfo.seed([998D58FCF337DF3E:C7206A3205827B0D]:0)
  at org.elasticsearch.action.support.tasks.TransportTasksAction$AsyncAction.onFailure(TransportTasksAction.java:312)
  at org.elasticsearch.action.support.tasks.TransportTasksAction$AsyncAction$1.handleException(TransportTasksAction.java:290)
  at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1377)
  at org.elasticsearch.transport.TransportService$5.doRun(TransportService.java:944)
  at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:958)
  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.lang.Thread.run(Thread.java:833)

  Caused by: org.elasticsearch.transport.SendRequestTransportException: [javaRestTest-2][127.0.0.1:37169][cluster:admin/xpack/ml/job/data/post[n]]

    at org.elasticsearch.transport.TransportService.handleInternalSendException(TransportService.java:928)
    at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:905)
    at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$2.sendRequest(SecurityServerTransportInterceptor.java:281)
    at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor.sendWithUser(SecurityServerTransportInterceptor.java:421)
    at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor.sendRequestInner(SecurityServerTransportInterceptor.java:256)
    at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$1.sendRequest(SecurityServerTransportInterceptor.java:187)
    at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:786)
    at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:732)
    at org.elasticsearch.action.support.tasks.TransportTasksAction$AsyncAction.start(TransportTasksAction.java:272)
    at org.elasticsearch.action.support.tasks.TransportTasksAction.doExecute(TransportTasksAction.java:89)
    at org.elasticsearch.xpack.ml.action.TransportJobTaskAction.doExecute(TransportJobTaskAction.java:64)
    at org.elasticsearch.xpack.ml.action.TransportJobTaskAction.doExecute(TransportJobTaskAction.java:33)
    at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:86)
    at org.elasticsearch.action.support.ActionFilter$Simple.apply(ActionFilter.java:53)
    at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:84)
    at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$3(SecurityActionFilter.java:163)
    at org.elasticsearch.action.ActionListener$DelegatingFailureActionListener.onResponse(ActionListener.java:250)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$6(AuthorizationService.java:436)
    at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:989)
    at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:955)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$7(AuthorizationService.java:450)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.security.authz.RBACEngine.authorizeClusterAction(RBACEngine.java:184)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.authorizeAction(AuthorizationService.java:440)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.maybeAuthorizeRunAs(AuthorizationService.java:416)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorize$3(AuthorizationService.java:317)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
    at org.elasticsearch.xpack.security.authz.RBACEngine.lambda$resolveAuthorizationInfo$0(RBACEngine.java:150)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.lambda$getRoles$1(CompositeRolesStore.java:201)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$0(RoleReferenceIntersection.java:49)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.action.support.GroupedActionListener.onResponse(GroupedActionListener.java:55)
    at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.buildRoleFromRoleReference(CompositeRolesStore.java:299)
    at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$1(RoleReferenceIntersection.java:53)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.buildRole(RoleReferenceIntersection.java:53)
    at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRole(CompositeRolesStore.java:216)
    at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRoles(CompositeRolesStore.java:191)
    at org.elasticsearch.xpack.security.authz.RBACEngine.resolveAuthorizationInfo(RBACEngine.java:147)
    at org.elasticsearch.xpack.security.authz.AuthorizationService.authorize(AuthorizationService.java:319)
    at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$4(SecurityActionFilter.java:159)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.action.ActionListener$MappedActionListener.onResponse(ActionListener.java:132)
    at org.elasticsearch.action.ActionListener$RunBeforeActionListener.onResponse(ActionListener.java:440)
    at org.elasticsearch.action.ActionListener$7.onResponse(ActionListener.java:546)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.writeAuthToContext(AuthenticatorChain.java:346)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.finishAuthentication(AuthenticatorChain.java:325)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.maybeLookupRunAsUser(AuthenticatorChain.java:202)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$doAuthenticate$1(AuthenticatorChain.java:121)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$4(AuthenticatorChain.java:188)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$5(RealmsAuthenticator.java:218)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141)
    at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$1(RealmsAuthenticator.java:163)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$1(CachingUsernamePasswordRealm.java:155)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.handleCachedAuthentication(CachingUsernamePasswordRealm.java:242)
    at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$2(CachingUsernamePasswordRealm.java:139)
    at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
    at org.elasticsearch.action.ActionListener.completeWith(ActionListener.java:510)
    at org.elasticsearch.common.util.concurrent.ListenableFuture.notifyListenerDirectly(ListenableFuture.java:111)
    at org.elasticsearch.common.util.concurrent.ListenableFuture.addListener(ListenableFuture.java:55)
    at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticateWithCache(CachingUsernamePasswordRealm.java:134)
    at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticate(CachingUsernamePasswordRealm.java:105)
    at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$4(RealmsAuthenticator.java:147)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117)
    at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.consumeToken(RealmsAuthenticator.java:234)
    at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.authenticate(RealmsAuthenticator.java:83)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:180)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
    at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.doAuthenticate(AuthenticatorChain.java:136)
    at org.elasticsearch.xpack.security.authc.AuthenticatorChain.authenticateAsync(AuthenticatorChain.java:95)
    at org.elasticsearch.xpack.security.authc.AuthenticationService.authenticate(AuthenticationService.java:171)
    at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.applyInternal(SecurityActionFilter.java:155)
    at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:114)
    at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:84)
    at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)
    at org.elasticsearch.tasks.TaskManager.registerAndExecute(TaskManager.java:203)
    at org.elasticsearch.client.internal.node.NodeClient.executeLocally(NodeClient.java:112)
    at org.elasticsearch.client.internal.node.NodeClient.doExecute(NodeClient.java:90)
    at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
    at org.elasticsearch.client.internal.FilterClient.doExecute(FilterClient.java:57)
    at org.elasticsearch.client.internal.support.AbstractClient$1.doExecute(AbstractClient.java:1727)
    at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
    at org.elasticsearch.client.internal.FilterClient.doExecute(FilterClient.java:57)
    at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
    at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:366)
    at org.elasticsearch.xpack.ml.integration.MlNativeAutodetectIntegTestCase.postData(MlNativeAutodetectIntegTestCase.java:224)
    at org.elasticsearch.xpack.ml.integration.ScheduledEventsIT.runJob(ScheduledEventsIT.java:476)
    at org.elasticsearch.xpack.ml.integration.ScheduledEventsIT.testScheduledEvents(ScheduledEventsIT.java:90)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:568)
    at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
    at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
    at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
    at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
    at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
    at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
    at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
    at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
    at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
    at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
    at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
    at java.lang.Thread.run(Thread.java:833)

    Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 16384 out of bounds for length 16384

      at org.elasticsearch.common.io.stream.RecyclerBytesStreamOutput.writeByte(RecyclerBytesStreamOutput.java:60)
      at org.elasticsearch.common.io.stream.StreamOutput.writeBoolean(StreamOutput.java:473)
      at org.elasticsearch.xpack.core.ml.action.PostDataAction$Request.writeTo(PostDataAction.java:128)
      at org.elasticsearch.action.support.tasks.TransportTasksAction$NodeTaskRequest.writeTo(TransportTasksAction.java:361)
      at org.elasticsearch.transport.OutboundMessage.serialize(OutboundMessage.java:70)
      at org.elasticsearch.transport.OutboundHandler.sendMessage(OutboundHandler.java:178)
      at org.elasticsearch.transport.OutboundHandler.sendRequest(OutboundHandler.java:105)
      at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:343)
      at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:903)
      at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$2.sendRequest(SecurityServerTransportInterceptor.java:281)
      at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor.sendWithUser(SecurityServerTransportInterceptor.java:421)
      at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor.sendRequestInner(SecurityServerTransportInterceptor.java:256)
      at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$1.sendRequest(SecurityServerTransportInterceptor.java:187)
      at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:786)
      at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:732)
      at org.elasticsearch.action.support.tasks.TransportTasksAction$AsyncAction.start(TransportTasksAction.java:272)
      at org.elasticsearch.action.support.tasks.TransportTasksAction.doExecute(TransportTasksAction.java:89)
      at org.elasticsearch.xpack.ml.action.TransportJobTaskAction.doExecute(TransportJobTaskAction.java:64)
      at org.elasticsearch.xpack.ml.action.TransportJobTaskAction.doExecute(TransportJobTaskAction.java:33)
      at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:86)
      at org.elasticsearch.action.support.ActionFilter$Simple.apply(ActionFilter.java:53)
      at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:84)
      at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$3(SecurityActionFilter.java:163)
      at org.elasticsearch.action.ActionListener$DelegatingFailureActionListener.onResponse(ActionListener.java:250)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$6(AuthorizationService.java:436)
      at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:989)
      at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:955)
      at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$7(AuthorizationService.java:450)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.security.authz.RBACEngine.authorizeClusterAction(RBACEngine.java:184)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.authorizeAction(AuthorizationService.java:440)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.maybeAuthorizeRunAs(AuthorizationService.java:416)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorize$3(AuthorizationService.java:317)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
      at org.elasticsearch.xpack.security.authz.RBACEngine.lambda$resolveAuthorizationInfo$0(RBACEngine.java:150)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.lambda$getRoles$1(CompositeRolesStore.java:201)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$0(RoleReferenceIntersection.java:49)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.action.support.GroupedActionListener.onResponse(GroupedActionListener.java:55)
      at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.buildRoleFromRoleReference(CompositeRolesStore.java:299)
      at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$1(RoleReferenceIntersection.java:53)
      at java.lang.Iterable.forEach(Iterable.java:75)
      at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.buildRole(RoleReferenceIntersection.java:53)
      at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRole(CompositeRolesStore.java:216)
      at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRoles(CompositeRolesStore.java:191)
      at org.elasticsearch.xpack.security.authz.RBACEngine.resolveAuthorizationInfo(RBACEngine.java:147)
      at org.elasticsearch.xpack.security.authz.AuthorizationService.authorize(AuthorizationService.java:319)
      at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$4(SecurityActionFilter.java:159)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.action.ActionListener$MappedActionListener.onResponse(ActionListener.java:132)
      at org.elasticsearch.action.ActionListener$RunBeforeActionListener.onResponse(ActionListener.java:440)
      at org.elasticsearch.action.ActionListener$7.onResponse(ActionListener.java:546)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.writeAuthToContext(AuthenticatorChain.java:346)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.finishAuthentication(AuthenticatorChain.java:325)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.maybeLookupRunAsUser(AuthenticatorChain.java:202)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$doAuthenticate$1(AuthenticatorChain.java:121)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$4(AuthenticatorChain.java:188)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$5(RealmsAuthenticator.java:218)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141)
      at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$1(RealmsAuthenticator.java:163)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$1(CachingUsernamePasswordRealm.java:155)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.handleCachedAuthentication(CachingUsernamePasswordRealm.java:242)
      at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$2(CachingUsernamePasswordRealm.java:139)
      at org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)
      at org.elasticsearch.action.ActionListener.completeWith(ActionListener.java:510)
      at org.elasticsearch.common.util.concurrent.ListenableFuture.notifyListenerDirectly(ListenableFuture.java:111)
      at org.elasticsearch.common.util.concurrent.ListenableFuture.addListener(ListenableFuture.java:55)
      at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticateWithCache(CachingUsernamePasswordRealm.java:134)
      at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticate(CachingUsernamePasswordRealm.java:105)
      at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$4(RealmsAuthenticator.java:147)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117)
      at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.consumeToken(RealmsAuthenticator.java:234)
      at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.authenticate(RealmsAuthenticator.java:83)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:180)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:158)
      at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.doAuthenticate(AuthenticatorChain.java:136)
      at org.elasticsearch.xpack.security.authc.AuthenticatorChain.authenticateAsync(AuthenticatorChain.java:95)
      at org.elasticsearch.xpack.security.authc.AuthenticationService.authenticate(AuthenticationService.java:171)
      at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.applyInternal(SecurityActionFilter.java:155)
      at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:114)
      at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:84)
      at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)
      at org.elasticsearch.tasks.TaskManager.registerAndExecute(TaskManager.java:203)
      at org.elasticsearch.client.internal.node.NodeClient.executeLocally(NodeClient.java:112)
      at org.elasticsearch.client.internal.node.NodeClient.doExecute(NodeClient.java:90)
      at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
      at org.elasticsearch.client.internal.FilterClient.doExecute(FilterClient.java:57)
      at org.elasticsearch.client.internal.support.AbstractClient$1.doExecute(AbstractClient.java:1727)
      at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
      at org.elasticsearch.client.internal.FilterClient.doExecute(FilterClient.java:57)
      at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380)
      at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:366)
      at org.elasticsearch.xpack.ml.integration.MlNativeAutodetectIntegTestCase.postData(MlNativeAutodetectIntegTestCase.java:224)
      at org.elasticsearch.xpack.ml.integration.ScheduledEventsIT.runJob(ScheduledEventsIT.java:476)
      at org.elasticsearch.xpack.ml.integration.ScheduledEventsIT.testScheduledEvents(ScheduledEventsIT.java:90)
      at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
      at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:568)
      at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
      at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
      at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
      at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
      at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
      at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
      at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
      at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
      at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
      at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
      at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
      at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
      at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
      at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
      at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
      at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
      at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
      at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
      at java.lang.Thread.run(Thread.java:833)

```
x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ScheduledEventsIT.java
List<Bucket> buckets = getBuckets(getBucketsRequest);
        
        for (int i = 0; i <= bucketCount; i++) {
            assertEquals(0, buckets.get(i).getScheduledEvents().size());
        }
        
        assertEquals(1, buckets.get(6).getScheduledEvents().size());
        assertEquals("Some Event", buckets.get(6).getScheduledEvents().get(0));
        assertEquals(1, buckets.get(7).getScheduledEvents().size());
        assertEquals("Some Event", buckets.get(7).getScheduledEvents().get(0));
        assertEquals(0, buckets.get(8).getScheduledEvents().size());
    }
    /**
     * An open job that later gets added to a calendar, should take the scheduled events into account
     */
    public void testAddOpenedJobToGroupWithCalendar() throws Exception {
        TimeValue bucketSpan = TimeValue.timeValueMinutes(30);
        String groupName = "opened-calendar-job-group";
        Job.Builder job = createJob("scheduled-events-add-opened-job-to-group-with-calendar", bucketSpan);
        long startTime = 1514764800000L;
        final int bucketCount = 5;
        
        openJob(job.getId());
        
        postData(
            job.getId(),
            generateData(startTime, bucketSpan, bucketCount, bucketIndex -> randomIntBetween(100, 200)).stream()
                .collect(Collectors.joining())
        );
        String calendarId = "test-calendar-open-job-update";