title: Kafka Streams - The state store may have migrated to another instance
body: <p>I'm writing a basic application to test the Interactive Queries feature of Kafka Streams. Here is the code:</p>
  <pre><code>public static void main(String[] args) {
      StreamsBuilder builder = new StreamsBuilder();
  
      KeyValueBytesStoreSupplier waypointsStoreSupplier = Stores.persistentKeyValueStore(&quot;test-store&quot;);
      StoreBuilder waypointsStoreBuilder = Stores.keyValueStoreBuilder(waypointsStoreSupplier, Serdes.ByteArray(), Serdes.Integer());
  
      final KStream&lt;byte[], byte[]&gt; waypointsStream = builder.stream(&quot;sample1&quot;);
  
      final KStream&lt;byte[], TruckDriverWaypoint&gt; waypointsDeserialized =  waypointsStream
                                                                          .mapValues(CustomSerdes::deserializeTruckDriverWaypoint)
                                                                          .filter((k,v) -&gt; v.isPresent())
                                                                          .mapValues(Optional::get);
  
      waypointsDeserialized.groupByKey().aggregate(
              () -&gt; 1,
              (aggKey, newWaypoint, aggValue) -&gt; {
  
                  aggValue = aggValue + 1;
                  return aggValue;
  
              }, Materialized.&lt;byte[], Integer, KeyValueStore&lt;Bytes, byte[]&gt;&gt;as(&quot;test-store&quot;).withKeySerde(Serdes.ByteArray()).withValueSerde(Serdes.Integer())
      );
  
      final KafkaStreams streams = new KafkaStreams(builder.build(), new StreamsConfig(createStreamsProperties()));
  
      streams.cleanUp();
      streams.start();    
  
      ReadOnlyKeyValueStore&lt;byte[], Integer&gt; keyValueStore = streams.store(&quot;test-store&quot;, QueryableStoreTypes.keyValueStore());
  
      KeyValueIterator&lt;byte[], Integer&gt; range = keyValueStore.all();
      while (range.hasNext()) {
          KeyValue&lt;byte[], Integer&gt; next = range.next();
          System.out.println(next.value);
  
      }
  
      Runtime.getRuntime().addShutdownHook(new Thread(streams::close));
  
  }
  
  
  protected static Properties createStreamsProperties() {
  
      final Properties streamsConfiguration = new Properties();
  
      streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, &quot;random167&quot;);
      streamsConfiguration.put(StreamsConfig.CLIENT_ID_CONFIG, &quot;client-id&quot;);
      streamsConfiguration.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, &quot;localhost:9092&quot;);
      streamsConfiguration.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, &quot;earliest&quot;);
      streamsConfiguration.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, Serdes.String().getClass().getName());
      streamsConfiguration.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, Serdes.Integer().getClass().getName());
      //streamsConfiguration.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 10000);
  
      return streamsConfiguration;
  }
  </code></pre>
  <p>So my problem is, every time I run this I get this same error:</p>
  <blockquote>
  <p>Exception in thread &quot;main&quot; org.apache.kafka.streams.errors.InvalidStateStoreException: the state store, test-store, may have migrated to another instance.</p>
  </blockquote>
  <p>I'm running only 1 instance of the application, and the topic I'm consuming from has only 1 partition.</p>
  <p>Any idea what I'm doing wrong ?</p>