Druid

Apache Druid 27.0.0 Deep Storage Query 테스트 실패 과정

justbagmeg 2023. 8. 29. 21:43

Deep Storage Query 

Apache Druid 27.0.0 릴리즈에 추가된 Deep Storage Query 기능을 테스트했다.

먼저 결론은 'kafka ingestion을 사용하는 지금 환경에서는 사용할 수 없다' 였다. Multi Stage Query는 Batch 데이터를 지원하지 kafka ingestion은 지원하지 않기 때문이다.

 

Deep Storage Query는 Historical 서비스를 거치지 않고 Deep Storage에 있는 데이터를 쿼리 할 수 있는 기능이다.

 

Deep Storage Query를 테스트 한 가장 큰 이유는 Historical 서비스의 disk 크기다. 

이전까지 드루이드는 Historical 서비스가 가지고 있는(memory, disk) 세그먼트의 범위 안 데이터만 쿼리 할 수 있었다. 이런 이유로 많은 과거 데이터를 조회하려면 historical 서비스가 자연적으로 거대한 disk를 가질 수밖에 없었다. 이 문제는 팀 내에서도 항상 문제가 됐었다. 요구하는 데이터의 시간 범위는 크지만 그만한 데이터를 historical이 모두 가지고 있기에는 disk문제도 있고 데이터 조회 시 발생할 속도 저하도 걱정 됐다.

 

Deep Storage Query를 사용하는 방법은 간단(할줄 알았다.. )하다. 

먼저 Deep Storage Query를 사용하기 위한 조건은, historical 서비스가 Deep Storage에서 조회할 데이터 소스의 세그먼트를 최소 하나 가지고 있어야 한다. 다음은 쿼리를 보낼 때 query context에 `"executionMode": "ASYNC"` 파라미터를 추가해야 한다. 마지막으로 Multi Stage Query engine을 추가해야한다. MSQ를 추가하지 않아 처음에 시간을 많이 허비했다. 

MSQ 엔진이 없으면 `405 method not allowed` 에러가 발생한다.

Deep Storage Query 실행

준비가 됐다면 아래처럼 쿼리를 작성한다.

// http://<라우터 주소>:<라우터 포트>/druid/v2/sql/statements
{
    "query": "SELECT * FROM <데이터 소스>",
    "context": {
        "executionMode":"ASYNC"
    }
}

아직 문서에는 없지만, http://<라우터 주소>:<라우터 포트>/druid/v2/sql/statements/enabled 와 같이 enabled 앤드포인트는 Deep Storage Query를 enable 됐는지 확인할 수 있다.

 

정상적으로 작동하면 아래처럼 state: ACCEPTED가 달린 결과가 나온다.

{
    "queryId": "...",
    "state": "ACCEPTED",
    "createdAt": "2023-08-27T21:59:02.334Z",
    "schema": [
        {
            "name": "name",
            "type": "VARCHAR",
            "nativeType": "STRING"
        }
    ],
    "durationMs": -1
}

이제 위에 나온 queryId를 이용해 Deep Storage Query가 실행 중인지 확인해 보자.

http://<라우터 주소>:<라우터 포트>/druid/v2/sql/statements/<qeuryId>

정상적으로 Deep Storage에서 쿼리가 실행 중이라면 state: RUNNING이라는 결과를 얻는다.

 

하지만 아래와 같은 결과가 나온다면 뭔가 문제가 있는 상황이다.

{
    "error": "druidException",
    "errorCode": "notFound",
    "persona": "USER",
    "category": "NOT_FOUND",
    "errorMessage": "Query [query-ashf983-asdgasg03-asgdlkkhj] was not found. The query details are no longer present or might not be of the type [query_controller]. Verify that the id is correct.",
    "context": {}
}

나는 위와 같은 에러가 발생했고 분석 결과 kafka ingestion을 사용하는 한 Deep Storage Query는 사용할 수 없다는 결론을 내렸다. 아닐 수도 있고? 

 

에러 메시지 분석

에러 메시지를 분석해 보자

"Query [query-ashf983-asdgasg03-asgdlkkhj] was not found. The query details are no longer present or might not be of the type [query_controller]. Verify that the id is correct."

 

메시지는 두개의 에러 발생 가능 원인을 알려주고 있다.

1. query-ashf983-asdgasg03-asgdlkkhj 라는 쿼리가 존재하지 않는다. -> 이미 이전 단계에서 쿼리가 ACCEPTED 된 것을 확인했기 때문에 쿼리 자체가 없다는 것은 말이 안 된다. 그렇기 때문에 이 문제는 아닐 것이다.

2.  might not be of the type [query_controller]. 쿼리가 query_controller 타입이 아니라고 한다. -> query controller가 뭐지? Batch ingestion을 하는 하나의 방법이다. MSQ에 대한 설명 중 다음 문장이 있다. `The druid-multi-stage-query extension adds a multi-stage query (MSQ) task engine that executes SQL statements as batch tasks in the indexing service, which execute on Middle Managers.` MSQ는 Batch ingestion을 하는 엔진이다. Batch ... kafka ingestion은 Batch ingestion이 아니라서 애초에 MSQ 엔진이 enabled 된 상태에서 작동하는 Deep Storage Query를 사용할 수 없는 것이었다.

 

 

틀린 내용이 있다면 알려세요. 수정할게요 😊😊

 


 

참고 링크

 

Release Druid 27.0.0 · apache/druid

Apache Druid 27.0.0 contains over 316 new features, bug fixes, performance enhancements, documentation improvements, and additional test coverage from 50 contributors. See the complete set of chang...

github.com

 

 

 

Tutorial: Query from deep storage | Apache® Druid

<!--

druid.apache.org

 

Query from deep storage | Apache® Druid

<!--

druid.apache.org

 

 

 

SQL-based ingestion | Apache® Druid

Introduces multi-stage query architecture and its task engine

druid.apache.org

 

Ingestion overview | Apache® Druid

<!--

druid.apache.org

 

'Druid' 카테고리의 다른 글

Apache Druid 설정 변경하기  (0) 2023.09.03
Apache Druid local 실행  (0) 2023.09.03