[Opensearch]cluster_block_exception

포동동·2023년 9월 23일
1

[유튜브 프로젝트]

목록 보기
13/13

문제 상황

kinesis firehose를 통해 들어오던 데이터가 어느 순간 {"type":"cluster_block_exception","reason":"index [인덱스명] blocked by: [FORBIDDEN/8/index write (api)];"} 에러 로그를 남기며 opensearch에 들어오지 않고 있다.

며칠 전부터 돌리던 크롤링 코드로 약 650만개의 데이터를 os로 넣고 있었다. 그러던 중 어제밤부터 데이터가 안 늘어나는 걸 확인하고 kinesis firehose를 모니터링해보니,

이렇게 6월20일 새벽 1시부터 에러가 났다는 것을 알게되었다. 로그를 확인해보니 계속해서 아래와 같은 로그를 생성하고 있었다.

바로 코드를 중단하고, 원인 분석에 나섰다.


원인 파악

AWS 공식문서에 따라 파악해본 결과, 가장 근본적인 원인은 클러스터의 상태가 Red나 Yellow가 되기 전에 자동으로 막는 것이다. 그리고 그렇게 상태가 바뀌는 가장 큰 원인은 아래와 같았다.

  1. JVM Memory Pressure

    When the JVMMemoryPressure metric exceeds 92% for 30 minutes, OpenSearch Service triggers a protection mechanism and blocks all write operations to prevent the cluster from reaching red status. When the protection is on, write operations fail with a ClusterBlockException error, new indexes can't be created, and the IndexCreateBlockException error is thrown.

  2. CPU Utilization

    If one or more nodes in your cluster has storage space less than the minimum value of 1) 20% of available storage space, or 2) 20 GB of storage space, basic write operations like adding documents and creating indexes can start to fail.


해결 방법

가장 간단한 해결방법은 이런 쿼리를 날리는 것이다.

PUT _cluster/settings
{
  "persistent": {
    "cluster.blocks.read_only": false
  }
}

간단하게, read_only로 block 하는 것을 허용하지 않겠다는 것인데, 아차피 read-only가 된다는 건 storage가 90% 이상 찼을 때 이기 때문에 근본적인 해결은 되지 않는다. 따라서 다른 방법을 찾아야했다.

profile
완료주의

0개의 댓글