개성있는 개발자 되기

카프카 이슈 - kafka-consumer-groups.sh --describe 에 정보가 없는 경우 본문

Open Source/Kafka

카프카 이슈 - kafka-consumer-groups.sh --describe 에 정보가 없는 경우

정몽실이 2020. 5. 20. 15:58

이슈 요약

현상 : 잘 작동했던 consumer-group이 갑자기 작동이 안됨

사유 : 컨슈머 그룹에 오프셋정보가 조회되지 않음, 주키퍼 서버 한대가 제대로 올라오지 않음

해결방법 : 주키퍼 재시작 -> 오프셋 할당되는지 확인


이슈 상세

 

특정 컨슈머가 올라오지 않아서, 컨슈머가 잘 등록되었는 지 확인했는데, result 값이 아무것도 보이지 않았다.

-- sh 실행
$ sh kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group test --describe
$ // 아무것도 없음
$

UI에서 보니까 문제가 있는건 확실했던게, consumer에 topic/partition이 아무것도 없었다.

 

구글링 해보니 Active한 consumer여도 한번도 commit이 안되었다면 kafka-consumer-groups.sh에는 아무내용을 보여주지 않는다는 것을 확인했다.

 

I think it's a little odd that kafka-consumer-groups doesn't show partition assignment at all, when there are no offsets.

 

Currently, if there are 2 partitions (partitions 1 and 2)

  • A) Active consumer, no committed offsets on either of them means that you see nothing. No group assignment, no partitions.
  • B) Active consumer, committed offsets on 1, no committed offsets on 2, means that you will see rows for both of them, but the CURRENT-OFFSET field for partition 2 will have a hyphen in it.
  • C) Active consumer, Committed offsets on both 1 and 2, means you will see all the data
  • D) No active consumer, committed offsets on both 1 and 2, means you will see the rows, but CONSUMER-ID/HOST/CLIENT-ID will have hyphens.

This Jira is talking about "A". // 이슈 현상은 A에 해당했다 
I would have expected that "A" would display similar to "B". That you would see partition assignments, but "-" wherever there are missing offsets.

 

https://issues.apache.org/jira/browse/KAFKA-7141

 

[KAFKA-7141] kafka-consumer-group doesn't describe existing group - ASF JIRA

I am running two consumers: akka-stream-kafka consumer with standard config section as described in the https://doc.akka.io/docs/akka-stream-kafka/current/consumer.html and  kafka-console-consumer. akka-stream-kafka consumer configuration looks like this

issues.apache.org

//

 

그래서 서버로그를 뒤짐

 

# 비정상케이스

보이는것처럼, item-ITEM-purge-consumer에 partition이 어사인 되지 않았다.

2020-05-20 14:26:59.975  INFO 67724 --- [tainer#14-6-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-98, groupId=item-ITEM-purge-consumer] Setting newly assigned partitions: 
2020-05-20 14:26:59.975  INFO 67724 --- [tainer#14-6-C-1] o.s.k.l.KafkaMessageListenerContainer    : item-ITEM-purge-consumer: partitions assigned: []

유관부서에 연락했더니 해당 컨슈머 오프셋정보가 조회되지 않았고 주키퍼를 재시작했더니 consumer에 오프셋이 할당 되었다.

 

다시 서버를 재기동하니 아래와 같이 다른 로그가 찍힌다.

# 정상케이스

2020-05-20 15:31:04.309  INFO 11180 --- [tainer#14-9-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-101, groupId=item-ITEM-purge-consumer] Setting offset for partition item-TABLE-item-1 to the committed offset FetchPosition{offset=0, offsetEpoch=Optional.empty, currentLeader=LeaderAndEpoch{leader=10.203.7.150:9092 (id: 1 rack: null), epoch=3}}
2020-05-20 15:31:04.309  INFO 11180 --- [tainer#14-8-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-100, groupId=item-ITEM-purge-consumer] Setting offset for partition item-TABLE-item-0 to the committed offset FetchPosition{offset=1, offsetEpoch=Optional.empty, currentLeader=LeaderAndEpoch{leader=10.203.7.150:9092 (id: 1 rack: null), epoch=4}}
2020-05-20 15:31:04.316  INFO 11180 --- [tainer#14-9-C-1] o.s.k.l.KafkaMessageListenerContainer    : item-ITEM-purge-consumer: partitions assigned: [item-TABLE-item-1]
2020-05-20 15:31:04.318  INFO 11180 --- [tainer#14-8-C-1] o.s.k.l.KafkaMessageListenerContainer    : item-ITEM-purge-consumer: partitions assigned: [item-TABLE-item-0]

위와 같이 제대로 파티셔닝이 되야 컨슈머가 작동된다.

 

//

그렇다면, consumer가 문제가 있는동안 보내져왔던 메시지들은 어떻게 될까?

확인해보니까, consumer는 LAG 상태로 있었으며, 정상복구가 된 이후로 주키퍼에 저장되어 있는 메시지들을 차례대로 읽어 오는 것을 확인했다. 

 

따라서, 이런 이슈가 생길때, consumer offset을 오류가 발생했던 시점의 offset 부터로 잘 설정해주는게 중요할 것 같다.

(개발이라서 0으로 초기화한것 같지만)

 

또한, 이런 이슈에 대한 대응법은 없을 듯하다.. Consumer의 오프셋이 할당되지 않은 케이스는 실제 운영에는 없었던 듯 하다.

(제발 없어야 하지만)

 

 

'Open Source > Kafka' 카테고리의 다른 글

Oracle 카프카 Connector 설치  (0) 2020.06.19
카프카 명령어  (0) 2020.04.01
Debezium 카프카 커넥트 메시지 Transform  (0) 2020.03.31
Debezium MySql CDC 카프카 커넥트  (3) 2020.03.26
Debezium Connector for MySQL  (0) 2020.03.25
Comments