Cannot open ccr restore session if shard closed – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when you attempt to restore a Cross-Cluster Replication (CCR) session in Elasticsearch, but the shard is closed. The shard needs to be open to restore the session. To resolve this issue, you can either manually open the shard using the ‘open index’ API or ensure that your cluster settings are configured to automatically open closed indices when a restore operation is attempted. Additionally, check your cluster health and ensure there are no underlying issues causing the shard to close unexpectedly.

This guide will help you check for common problems that cause the log ” cannot open ccr restore session if shard closed ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: restore, shard, repository, plugin.

Log Context

Log “cannot open ccr restore session if shard closed” class name is CcrRestoreSourceService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 logger.debug("not opening new session [{}] as it already exists"; sessionUUID);
 restore = onGoingRestores.get(sessionUUID);
 } else {
 logger.debug("opening session [{}] for shard [{}]"; sessionUUID; indexShard.shardId());
 if (indexShard.state() == IndexShardState.CLOSED) {
 throw new IndexShardClosedException(indexShard.shardId(); "cannot open ccr restore session if shard closed");
 }
 final Engine.IndexCommitRef commitRef = indexShard.acquireSafeIndexCommit();
 final Set fileNames = Set.copyOf(commitRef.getIndexCommit().getFileNames());
 restore = new RestoreSession(sessionUUID; indexShard; commitRef; fileNames; scheduleTimeout(sessionUUID));
 onGoingRestores.put(sessionUUID; restore);

 

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?