Kafka Exception InvalidStateStorePartitionException
org.apache.kafka.streams.errors.InvalidStateStorePartitionException
Non-retriable
Streams
Indicates that the specific state store being queried via StoreQueryParameters used a partitioning that is not assigned to this instance. You can use metadataForAllStreamsClients() to discover the correct instance that hosts the requested partition.
Common Causes
- An interactive query targets a specific partition (`StoreQueryParameters.withPartition(p)`) that the local instance does not host — the data for that key lives on another instance/partition.
- The partition number passed is out of range for the store (not in 0..numPartitions-1), so it simply doesn't exist for that store.
- Transient timing during rebalance/restoration: a partition that will be local isn't assigned yet at query time (this even shows up as flakiness in Kafka's own integration tests).
- Routing logic queries before resolving key→partition→host metadata, so it asks the wrong instance for the partition.
Solutions
- Resolve placement first with `KafkaStreams#queryMetadataForKey(store, key, serializer)` (or `streamsMetadataForStore`), then send the query to the host that actually owns that partition (RPC/HTTP fan-out).
- Validate the partition argument is within the store's partition count before calling `withPartition(...)`; omit `withPartition` to query all local partitions instead.
- Ensure the instance is RUNNING and, if you want to query during restore/standby, enable stale stores via `StoreQueryParameters.enableStaleStores()`.
- Add retry-with-backoff after confirming placement, to ride out rebalances where the partition is briefly unavailable.
Example Stack Trace
org.apache.kafka.streams.errors.InvalidStateStorePartitionException: The specified partition 1 for store source-table does not exist.
at org.apache.kafka.streams.state.internals.QueryableStoreProvider.getStore(QueryableStoreProvider.java:75)
at org.apache.kafka.streams.KafkaStreams.store(KafkaStreams.java:1190)
at com.example.streams.PartitionQueryService.queryPartition(PartitionQueryService.java:53)Diagnostic Commands
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic <application.id>-<store>-changelog # confirm the store's partition count / valid partition rangeRelated
Related Streams exceptions: BrokerNotFoundException · InternalTopicsAlreadySetupException · InvalidStateStoreException · LockException · MisconfiguredInternalTopicException · MissingInternalTopicsException · MissingSourceTopicException · ProcessorStateException
Hitting
InvalidStateStorePartitionException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.