I often get Timeout exceptions due to various reasons in my Kafka producer. I am using all the default values for producer config currently.
I have seen following Timeout exceptions:
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic-1-0: 30001 ms has passed since last append
I have following questions:
What are the general causes of these Timeout exceptions?
- Temporary network issue
- Server issue? if yes then what kind of server issue?
what are the general guidelines to handling the Timeout exception?
- Set 'retries' config so that Kafka API does the retries?
- Increase 'request.timeout.ms' or 'max.block.ms' ?
- Catch the exception and have application layer retry sending the message but this seems hard with Async send as messages will then be sent out of order?
Are Timeout exceptions retriable exceptions and is it safe to retry them?
I am using Kafka v2.1.0 and Java 11.
Thanks in advance.