简体   繁体   English

Kafka Streams:商店尚未准备就绪

[英]Kafka Streams: Store is not ready

We recently upgraded Kafka to v1.1 and Confluent to v4.0.But upon upgrading we have encountered a persistent problems regarding state stores. 我们最近将Kafka升级到v1.1,将Confluent升级到v4.0。但是在升级后,我们遇到了有关状态存储的持续问题。 Our application starts a collection of streams and we check for the state stores to be ready before killing the application after 100 tries. 我们的应用程序开始收集流,并在100次尝试后杀死该应用程序之前检查状态存储区是否准备就绪。 But after the upgrade there's atleast one stream that will have Store is not ready : the state store, <your stream>, may have migrated to another instance The stream itself has RUNNING state and the messages will flow through but the state of the store still shows up as not ready. 但是升级后,至少有一个流将没有Store is not ready : the state store, <your stream>, may have migrated to another instance流本身具有RUNNING状态,消息将流过,但存储状态仍然显示为未准备好。 So I have no idea as to what may be happening. 所以我不知道会发生什么。

  • Should I not check for store state? 我不应该检查商店状态吗?
  • And since our application has a lot of streams (~15), would starting them simultaneously cause problems? 并且由于我们的应用程序有很多流(〜15个),因此同时启动它们会引起问题吗?
  • Should we not do a hard restart -- currently we run it as a service on linux 我们是否应该进行硬重启-目前我们在Linux上将其作为服务运行

We are running Kafka in cluster with 3 brokers.Below is a sample stream (not the entire code): 我们在3个代理的集群中运行Kafka,下面是一个示例流(不是整个代码):

public BaseStream createStreamInstance() {
    final Serializer<JsonNode> jsonSerializer = new JsonSerializer();
    final Deserializer<JsonNode> jsonDeserializer = new JsonDeserializer();
    final Serde<JsonNode> jsonSerde = Serdes.serdeFrom(jsonSerializer, jsonDeserializer);

    MessagePayLoadParser<Note> noteParser = new MessagePayLoadParser<Note>(Note.class);
    GenericJsonSerde<Note> noteSerde = new GenericJsonSerde<Note>(Note.class);

    StreamsBuilder builder = new StreamsBuilder();

    //below reducer will use sets to combine
    //value1 in the reducer is what is already present in the store.
    //value2 is the incoming message and for notes should have max 1 item in it's list (since its 1 attachment 1 tag per row, but multiple rows per note)
    Reducer<Note> reducer = new Reducer<Note>() {
        @Override
        public Note apply(Note value1, Note value2) {
            value1.merge(value2);
            return value1;
        }
    };

    KTable<Long, Note> noteTable = builder
            .stream(this.subTopic, Consumed.with(jsonSerde, jsonSerde))
            .map(noteParser::parse)
            .groupByKey(Serialized.with(Serdes.Long(), noteSerde))
            .reduce(reducer);

    noteTable.toStream().to(this.pubTopic, Produced.with(Serdes.Long(), noteSerde));

    this.stream = new KafkaStreams(builder.build(), this.properties);
    return this;
}

There are some open questions here, like the ones Matthias put on comment, but will try to answer/give help to your actual questions: 这里有一些未解决的问题,例如马蒂亚斯(Matthias)提出的问题,但会尝试回答/为您的实际问题提供帮助:

  • Should I not check for store state? 我不应该检查商店状态吗? Rebalancing is usually the case here. 此处通常是重新平衡。 But in that case, you should not see that partition's thread keep consuming, but that processing should be "transferred" to be done to another thread that took over. 但是在那种情况下,您不应看到分区的线程不断消耗,而应将处理“转移”到另一个接管的线程上。 Make sure if it is actually that very thread the one that keeps on processing that partition, and not the new one. 确保确实是那个线程正在继续处理该分区,而不是新线程 Check kafka-consumer-groups utility to follow the consumers (threads) there. 检查kafka-consumer-groups实用程序以关注那里的使用者(线程)。
  • And since our application has a lot of streams (~15), would starting them simultaneously cause problems? 并且由于我们的应用程序有很多流(〜15个),因此同时启动它们会引起问题吗? No, rebalancing is automatic. 不,重新平衡是自动的。
  • Should we not do a hard restart -- currently we run it as a service on linux Are you keeping your state stores in a certain, non-default directory? 我们是否应该不进行硬重启-目前我们在Linux上将其作为服务运行,您是否将状态存储保存在某个非默认目录中? You should configure your state stores directory properly and make sure it is accessible, insensitive to application restarts. 您应该正确配置状态存储目录,并确保该目录可访问,并且对应用程序重启不敏感。 Unsure about how you perform your hard restart, but some exception handling code should cover against it, closing your streams application. 不确定如何执行硬重启,但是应该涵盖一些异常处理代码,从而关闭流应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM