Skip to content

Commit

Permalink
KAFKA-13761: KafkaLog4jAppender deadlocks when idempotence is enabled (
Browse files Browse the repository at this point in the history
…apache#11939)

When a log entry is appended to a Kafka topic using KafkaLog4jAppender, the producer.send operation
may hit a deadlock if the producer network thread also tries to append a log at the same log level.
This issue is triggered when idempotence is enabled for the KafkaLog4jAppender and the producer
tries to acquire the TransactionManager lock.

This is a temporary workaround to avoid deadlocks by disabling idempotence explicitly in
KafkaLog4jAppender.

Reviewers: Luke Chen <[email protected]>, Ismael Juma <[email protected]>
  • Loading branch information
yyu1993 authored Mar 24, 2022
1 parent 12bb231 commit db724f2
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.apache.kafka.clients.producer.ProducerConfig.MAX_BLOCK_MS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.RETRIES_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG;
import static org.apache.kafka.common.config.SaslConfigs.SASL_JAAS_CONFIG;
import static org.apache.kafka.common.config.SaslConfigs.SASL_KERBEROS_SERVICE_NAME;
import static org.apache.kafka.common.config.SaslConfigs.SASL_MECHANISM;
Expand Down Expand Up @@ -290,6 +291,9 @@ public void activateOptions() {
props.put(DELIVERY_TIMEOUT_MS_CONFIG, deliveryTimeoutMs);
props.put(LINGER_MS_CONFIG, lingerMs);
props.put(BATCH_SIZE_CONFIG, batchSize);
// Disable idempotence to avoid deadlock when the producer network thread writes a log line while interacting
// with the TransactionManager, see KAFKA-13761 for more information.
props.put(ENABLE_IDEMPOTENCE_CONFIG, false);

if (securityProtocol != null) {
props.put(SECURITY_PROTOCOL_CONFIG, securityProtocol);
Expand Down

0 comments on commit db724f2

Please sign in to comment.