Skip to content

Commit db724f2

Browse files
authored
KAFKA-13761: KafkaLog4jAppender deadlocks when idempotence is enabled (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]>
1 parent 12bb231 commit db724f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

log4j-appender/src/main/java/org/apache/kafka/log4jappender/KafkaLog4jAppender.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import static org.apache.kafka.clients.producer.ProducerConfig.MAX_BLOCK_MS_CONFIG;
4444
import static org.apache.kafka.clients.producer.ProducerConfig.RETRIES_CONFIG;
4545
import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;
46+
import static org.apache.kafka.clients.producer.ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG;
4647
import static org.apache.kafka.common.config.SaslConfigs.SASL_JAAS_CONFIG;
4748
import static org.apache.kafka.common.config.SaslConfigs.SASL_KERBEROS_SERVICE_NAME;
4849
import static org.apache.kafka.common.config.SaslConfigs.SASL_MECHANISM;
@@ -290,6 +291,9 @@ public void activateOptions() {
290291
props.put(DELIVERY_TIMEOUT_MS_CONFIG, deliveryTimeoutMs);
291292
props.put(LINGER_MS_CONFIG, lingerMs);
292293
props.put(BATCH_SIZE_CONFIG, batchSize);
294+
// Disable idempotence to avoid deadlock when the producer network thread writes a log line while interacting
295+
// with the TransactionManager, see KAFKA-13761 for more information.
296+
props.put(ENABLE_IDEMPOTENCE_CONFIG, false);
293297

294298
if (securityProtocol != null) {
295299
props.put(SECURITY_PROTOCOL_CONFIG, securityProtocol);

0 commit comments

Comments
 (0)