Briefly, this error occurs when an attempt is made to delete a snapshot while it is being restored. Elasticsearch does not allow this operation because it could lead to data inconsistency or loss. To resolve this issue, you can either wait for the restore process to complete before deleting the snapshot, or cancel the ongoing restore operation before proceeding with the deletion. Always ensure to have a backup of your data before performing such operations to prevent any potential data loss.
This guide will help you check for common problems that cause the log ” cannot delete snapshot during a restore ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: snapshot, delete, restore.
Overview
DELETE is an Elasticsearch API which removes a document from a specific index. This API requires an index name and _id document to delete the document.
Delete a document
DELETE /my_index/_doc/1
Notes
- A delete request throws 404 error code if the document does not already exist in the index.
- If you want to delete a set of documents that matches a query, you need to use delete by query API.
Overview
In Elasticsearch, restore refers to the snapshot restore mechanism, which returns indices or clusters to a previous, saved state. You can restore the entire cluster from the snapshot or restore an individual index or selected indices.
Examples
To restore the whole snapshot:
POST /_snapshot/my_backup/snapshot-01-11-2019/_restore
To restore an individual index:
POST /_snapshot/my_backup/snapshot-01-11-2019/_restore { "indices": "my_index" }
Notes
- If you are using a security tool like Searchguard, the snapshot restore capability must be enabled in elasticsearch.yml. Otherwise, it will throw a security exception.
Common issues
- If an index or indices already exist with the same names as those you are going to restore, they need to either be closed or deleted before you can restore from a snapshot. Otherwise, the restore operation will fail due to an error that the index already exists.
Log Context
Log “cannot delete snapshot during a restore” class name is SnapshotsService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :
if (restoreInProgress != null) { // don't allow snapshot deletions while a restore is taking place; // otherwise we could end up deleting a snapshot that is being restored // and the files the restore depends on would all be gone if (restoreInProgress.isEmpty() == false) { throw new ConcurrentSnapshotExecutionException(snapshot; "cannot delete snapshot during a restore"); } } ClusterState.Builder clusterStateBuilder = ClusterState.builder(currentState); SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE); SnapshotsInProgress.Entry snapshotEntry = snapshots != null ? snapshots.snapshot(snapshot) : null;
[ratemypost]