faust
faust copied to clipboard
Default replication for replicas is 0 if replicas is None, is this a valid choice?
I am not very familiar with Kafka; however, when used with single instance Kafka and Redpanda on my development environment, RPC requests (agent.ask()) causes this error:
[^Worker]: Error: InvalidReplicationFactorError('Cannot create topic: f-reply-664f489d-06e6-4f66-b8ff-14fbb3cd8b67 (38): Replication factor must be greater than 0')
Same error with if app.conf.reply_create_topic is set to True even with topic_replication_factor is set to 1
https://github.com/faust-streaming/faust/blob/466dbf2f2241a5d4fda1c343075faa7265ab7b04/faust/topics.py#L498
When I change the default value to 1 from 0, RPC works as intended.
I believe I am missing something here? Will this change break things in the production deployments with Kafka clusters?
this works also
https://github.com/robinhood/faust/pull/227/files
As per Kafka documentation replication factor 0 does not make sense:
Kafka is meant to be used with replication by default—in fact we implement un-replicated topics as replicated topics where the replication factor is one.
see: https://kafka.apache.org/documentation/#replication
I do not know why this worked in the past ( id does not appear to work with a current version of kafka), but the change might be related to:
KIP-464: Defaults for AdminClient#createTopic
Which enabled the usage of default replication values for topics.
KIP-464 lead to some small changes in the topic creation in Kafka, among other things the magic value of '-1' can be used in the number of topic repications to create the default number of replications. ( see here https://github.com/a0x8o/kafka/blob/6e85b1a9d55bfe7db214baa1e4509d2db4e3637a/clients/src/main/java/org/apache/kafka/common/requests/CreateTopicsRequest.java#L83 )
Hence '-1' might actually be a better value than '0' in the absence of an explicit number of replications.
How do you supply the replication factor for reply topics to work around this issue?
topic_replication_factor=1 still results in the error.
I can confirm that this also produces this error, confusingly:
from faust import App
app = App('example', broker='kafka://localhost:9092')
topic = app.topic('example-topic', replicas=1)