節(jié)點(diǎn)快速失聯(lián)重連導(dǎo)致的shard失敗, failed to obtain in-memory lock

發(fā)現(xiàn)問題


image.png
image.png
image.png

shard屬于unassign的狀態(tài), 直接的信息可以看到是failed to create shard. failed to obtain in-memory shard.
shard只有在擁有shard的節(jié)點(diǎn)關(guān)機(jī)重啟(與master失去聯(lián)系, 即master不知道shard的狀態(tài)才會被重新分配).
所以表象問題有兩個:

  1. shard為什么會重新分配? 如果是節(jié)點(diǎn)重啟, 為什么?
  2. shard為什么不能被創(chuàng)建?

通過查看日志, 得知此節(jié)點(diǎn)由于負(fù)載過高, full-gc時間過長, 而導(dǎo)致與master的心跳中斷, 但是gc結(jié)束后, 又迅速重新加入的集群 , 而節(jié)點(diǎn)的此shard上正在被關(guān)閉, 且一直沒有成功關(guān)閉.

獲取鎖的代碼: org.opensearch.index.IndexService#createShard. 獲取鎖失敗的根因是因?yàn)? closing shard 持有著鎖, 且沒有放棄. 導(dǎo)致create在超過約定的重試次數(shù)后就不再創(chuàng)建了.

由于沒有開debug日志, 沒有關(guān)于為什么close shard的日志.

為什么負(fù)載高, 在節(jié)點(diǎn)離開集群前, 看到有兩個執(zhí)行了十幾秒的查詢, 而后在這個shard上還有2m的查詢, 應(yīng)該是它們導(dǎo)致的負(fù)載變高

解決:

/_cluster/reroute?retry_failed=true

不會丟失數(shù)據(jù), 觸發(fā)重新分配.

或者重啟節(jié)點(diǎn), 就可以釋放掉內(nèi)存鎖.但是可能部分丟失數(shù)據(jù)

GET /_cat/indices?v&health=yellow

查看處于亞健康的index

GET _cluster/allocation/explain

查看為什么分配失敗, 原因是什么, 就不用查日志了.

參考:

https://aws.amazon.com/cn/premiumsupport/knowledge-center/opensearch-in-memory-shard-lock/

https://elasticsearch.cn/question/3998

https://github.com/elastic/elasticsearch/issues/23199

image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容