Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Working In Process

Table of Contents

Status

Current state[One of "Under Discussion", "Accepted", "Rejected"]

Discussion thread: here

JIRA

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-5876

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

As the moment the IQ is only thrown InvalidStateStoreException for all errors. That means we Currently, IQ throws InvalidStateStoreException for any types of error, that means a user cannot handle different types of errors. We error.

Because of that, we should throw different exceptions for different typeseach type.

Proposed Changes

Add two new exception class for the IQ state store errors:

  • org.apache.kafka.streams.errors.StateStoreMigratedException
  • org.apache.kafka.streams.errors.StateStoreClosedException
StateStoreMigratedException used in the QueryableStoreProvider, StreamThreadStateStoreProvider and WrappingStoreProvider. The user can catch the exception and just wait until the store recreation finished.

 

 

To distinguish different types of error, we need to handle all InvalidStateStoreExceptions better during these public methods invoked. The main change is to introduce new exceptions that extend from InvalidStateStoreException. InvalidStateStoreException is not thrown at all anymore, but only new sub-classes.

Code Block
languagejava
# Two category exceptions
public class RetryableStateStoreException extends InvalidStateStoreException
public class FatalStateStoreException extends InvalidStateStoreException


# Retryable exceptions
public class StreamThreadNotStartedException extends RetryableStateStoreException
public class StreamThreadRebalancingException extends RetryableStateStoreException
public class StateStoreMigratedException extends RetryableStateStoreException


# Fatal exceptions
public class StreamThreadNotRunningException extends FatalStateStoreException

Various state store exceptions can classify into two category exceptions: RetryableStateStoreException and FatalStateStoreException. The user can use the two exceptions if they only need to distinguish whether it can retry.

  • Retryable exceptions
    • StreamThreadNotStartedException: will be thrown when streams thread state is CREATED, the user can retry until to RUNNING.
    • StreamThreadRebalancingException: will be thrown when stream thread is not running and stream state is REBALANCING, the user just retry and wait until rebalance finished (RUNNING).
    • StateStoreMigratedException: will be thrown when state store already closed and stream state is REBALANCING.
  • Fatal exceptions
    • KafkaStreamsNotRunningException: will be thrown when stream thread is not running and stream state is PENDING_SHUTDOWN / NOT_RUNNING / ERROR. The user cannot retry when this exception is thrown.
    • StateStoreNotAvailableException: will be thrown when state store closed and stream thread is PENDING_SHUTDOWN / NOT_RUNNING / ERROR. The user cannot retry when this exception is thrown.
    • UnknownStateStoreException: will be thrown when passing an unknown state store.


The following is the public methods that users will call to get state store instance:

  • KafkaStreams
    • store(storeName, queryableStoreType)
Info
Throw exceptions: StreamThreadNotStartedException, StreamThreadRebalancingException, KafkaStreamsNotRunningExceptionUnknownStateStoreException


The following is the public methods that users will call to get store values:

  • interface ReadOnlyKeyValueStore(class CompositeReadOnlyKeyValueStore)
    • get(key)
    • range(from, to)
    • all()
    • approximateNumEntries()
  • interface ReadOnlySessionStore(class CompositeReadOnlySessionStore)
    • fetch(key)
    • fetch(from, to)
  • interface ReadOnlyWindowStore(class CompositeReadOnlyWindowStore)
    • fetch(key, time)
    • fetch(key, from, to)

    • fetch(from, to, fromTime, toTime)
    • all()
    • fetchAll(from, to)
    • @Deprecated fetch(key, timeFrom, timeTo)
    • @Deprecated fetch(from, to, timeFrom, timeTo)
    • @Deprecated fetchAll(timeFrom, timeTo)
  • interface KeyValueIterator(class DelegatingPeekingKeyValueIterator)
    • next()
    • hasNext()
    • peekNextKey()
Info

All the above methods could be throw following exceptions: 

StreamThreadRebalancingExceptionStateStoreMigratedExceptionKafkaStreamsNotRunningExceptionStateStoreNotAvailableException

...


Compatibility, Deprecation, and Migration Plan

  • Because no classes will be removedAll new exceptions extend from InvalidStateStoreException, this change will be fully backward compatible.

Rejected Alternatives

...

None.


G
M
T












Text-to-speech function is limited to 200 characters