Symptoms
If you use a Go client that is developed based on the Sarama library, the following issues may occur:
- After you add a partition for a topic, the client cannot detect the new partition or consume messages in the partition. You must restart the client to enable the client to consume messages from the new partition.
- If the client subscribes to more than two topics, the client may fail to consume messages from specific partitions.
- If the policy for resetting consumer offsets of the client is set to
Oldest(earliest)
, the client may start to consume messages from the earliest offset after the client breaks down or the broker version is updated. This issue occurs because the out_of_range class is implemented in the code of the client.
Solutions
We recommend that you replace the Go client that is developed based on the Sarama library with a Go client that is developed by using Confluent at the earliest opportunity.
For information about the demo of the Go client that is developed by using Confluent, see kafka-confluent-go-demo.
Important If you cannot replace the client, perform the following operations:
- In your production environment, set the policy for resetting consumer offsets to
Newest(latest)
. In your debugging environment or other environments in which messages can be repeatedly consumed, set the policy for resetting consumer offsets toOldest(earliest)
. - If a consumer offset is reset and a large number of messages are queued, you can reset the consumer offset to the offset at a specified point in time in the ApsaraMQ for Kafka console. This way, you do not need to modify the client code or change the consumer group to reset the consumer offset. For more information, see Reset consumer offsets.