背景:Es删除过期快照时,后台日志报出以下异常信息。不能同时删除多个快照。如果你试图删除另一个快照,而你的上一个快照正在被删除,你将得到以下错误:
代码语言:javascript复制Caused by: org.elasticsearch.client.ResponseException: method [DELETE], host [http://localhost:9200], URI [/_snapshot/es_bak_20200220/snapshot-2021-08-16?master_timeout=30s], status line [HTTP/1.1 503 Service Unavailable]
{
"error":{
"root_cause":[
{
"type":"concurrent_snapshot_execution_exception",
"reason":"[es_bak_20200220:snapshot-2021-08-16/iTsJV_pFQEaN1o2YW2eQfg] cannot delete - another snapshot is currently being deleted"
}
],
"type":"concurrent_snapshot_execution_exception",
"reason":"[es_bak_20200220:snapshot-2021-08-16/iTsJV_pFQEaN1o2YW2eQfg] cannot delete - another snapshot is currently being deleted"
},
"status":503
}
说明:由于在删除快照的时候通过遍历获取全部过期快照,并依次删除,在第一个快照执行删除快照未完成时,第二个删除快照开始,导致异常的发生。