Cluster state has not been recovered yet cannot write to the security index – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.1

Briefly, this error occurs when Elasticsearch is trying to write to the security index before the cluster state has been fully recovered. This could be due to a slow recovery process or a premature write attempt. To resolve this issue, you can either wait for the cluster state to fully recover before attempting to write to the security index, or you can manually force a cluster state recovery. Additionally, ensure that your Elasticsearch nodes have sufficient resources to avoid slow recovery times.

This guide will help you check for common problems that cause the log ” Cluster state has not been recovered yet; cannot write to the security index ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, cluster, index.

Log Context

Log “Cluster state has not been recovered yet; cannot write to the security index” class name is SecurityIndexManager.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 */
 public void prepareIndexIfNeededThenExecute(final Consumer consumer; final Runnable andThen) {
 final State indexState = this.indexState; // use a local copy so all checks execute against the same state!
 // TODO we should improve this so we don't fire off a bunch of requests to do the same thing (create or update mappings)
 if (indexState == State.UNRECOVERED_STATE) {
 consumer.accept(new ElasticsearchStatusException("Cluster state has not been recovered yet; cannot write to the security index";
 RestStatus.SERVICE_UNAVAILABLE));
 } else if (indexState.indexExists && indexState.isIndexUpToDate == false) {
 consumer.accept(new IllegalStateException(
 "Security index is not on the current version. Security features relying on the index will not be available until " +
 "the upgrade API is run on the security index"));

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?