-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KafkaContainer transactions: Timeout expired while initializing transactional state in 60000ms. #1816
Comments
I just had a quick check with our
It happens on |
@gAmUssA any idea? :) |
you need to configure some of the broker parameters in order transaction state store will be initialized correctly. NOTE: it's always good to enable log output from the container to debug this kind of issues.
Let me know if you have any questions. @bsideup @kiview do you want me to send PR with a test for this issue? |
Thanks for the information. |
Thanks for this information !!! |
This should be part of default Kafka test container config, since (AFAIK) it always runs in a single broker configuration. |
The default value of |
I did have this transaction.state.log.replication.factor set to 1 but still seeing this error in producer.initTransaction() "Timeout expired while initializing transactional state in 60000ms" |
It went to following code, got the transactionManager.initializeTransactions into result but timing out in last line result.await(maxBlockTimeMs, TimeUnit.MILLISECONDS); |
Note there are 2 props to change. Do not try to debug the client code. It’s an server error. |
I have both properties set and I have numBroker=1. properties.put("transaction.state.log.replication.factor", Short.valueOf("1")); |
I have 10 nodes cluster with the following configuration: Kafka Stream log (Exactly once enabled, static group membership enabled):
` 2020-01-30 11:23:00 [Processor-StreamThread-1] ERROR o.a.k.s.p.internals.StreamTask - stream-thread [Processor-StreamThread-1] task [0_0] Timeout exception caught when initializing transactions for task 0_0. This might happen if the broker is slow to respond, if the network connection to the broker was interrupted, or if similar circumstances arise. You can increase producer parameter org.apache.kafka.streams.errors.StreamsException: stream-thread [Processor-StreamThread-1] Failed to rebalance. This is a big problem, I don't know what to do. This happens occasionally and kafka stream application (client) could not be started (i.e. transition to RUNNING state) before the brokers are restarted manually. Additional info: Kafka client/broker: 2.4.0
I appreciate any help! Thank you |
@ivanprostran this sounds like a problem with Kafka / your app and does not seem to be related to Testcontainers' Kafka module. |
Thank you for the info. I saw the same error and I am desperate. |
I will post it to different group (sorry for the inconvenience) |
@gAmUssA I've tried your setup regarding: I've made a debug on the spring library code and on my side it gets stuck on |
@pancudaniel7 could you share a reproducer? |
I am also getting same exception. I am using 'KafkaTemplate' with 'executeInTransaction' props.put(ProducerConfig.ACKS_CONFIG, "all");
props.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 10000);
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
props.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "prod-0"); // I am really not clear what this is for. I set it once in the producerConfig. Then create KafkaTemplate and use it many times... This is how I call Kafka template: kafkaTemplate.setTransactionIdPrefix(message.getGuid()); // I am also not sure about this line. I tried to put a unique value to prevent same message to be created twice.
kafkaTemplate.executeInTransaction(kafkaTemplate -> {
ListenableFuture<SendResult<String, Event>> future = kafkaTemplate.send(topic, message);
future.addCallback(new ListenableFutureCallback<SendResult<String, Event>>() {
@Override
public void onSuccess(SendResult<String, Event> result) {
}
@Override
public void onFailure(Throwable ex) {
}
});
return null;
}); This is what I receive
|
Same problem here :( I'm using Flink job with FlinkKafkaProducer.Semantic.EXACTLY_ONCE. When using same job without Test Containers everything is working fine. |
@maver1ck the transactions are not enabled by default, see @gAmUssA's answer: |
@bsideup checking this EDIT: It works. Thanks. |
This did the trick for me 👆❤️ In case anyone has the same issue using
|
Hi everyone, Unfortunately I have the same error:
In the console output I see this:
My configuration of KafkaContainer :
And my configuration in the application.yml looks like this:
I'm not getting it to start up successfully, has anyone been able to overcome this? |
kafka.addEnv("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "2") |
If I use :
The error is the same. If I use 1 for both, I got this:
|
@kcotzen it should be |
I used value 1 for both, and I got this error:
|
I made some modifications(I removed use of chainedTransactionManager), and it works Zero errors in console output, but when I use chainedTransactionManager :
sounds weird. Any ideas please? |
well, for some reason the problem was caused by the chainedTransactionManager definition, I think the console output is very weird and led me to confusion. |
I got the same issue while trying to apply transaction producers. if you are using Kafka container with docker then most likely you will go with: |
I'm trying create a test that uses kafka transactions. If I use a local instance of Kafka instead of KafkaContainer everything works fine, but when I use KafkaContainer it fails and I see the following:
Timeout expired while initializing transactional state in 60000ms.
org.apache.kafka.common.errors.TimeoutException: Timeout expired while initializing transactional state in 60000ms.
Attached are the source for my test and the logfile from the run.
kafka.log
Test.java.txt
The text was updated successfully, but these errors were encountered: