You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Status

Current stateUnder Discussion

Discussion thread: here 

JIRA: here or here

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

Motivation

Currently there is not a native way to shutdown and entire KStreams application from a StreamThread. This functionality would be useful for immediately halting processing to prevent data from being corrupted.

This would help recover form errors or problems such the following:

  • source/sink topic deleted. A handler will be exposed to a the users created for error source topics in KIP-662.
  • Serialization or Deserialization failures. This can add another option to prevent rolling thread death.
    • currently they have the option of returning a Continue or Fail Enum. In the future we can expand this to include Shutdown and then throw ShutdownRequestedException in response
  • Add another option in KIP-399 if failing and having only the thread fail is not comprehensive enough
  • User specific cases such as  Unable to render Jira issues macro, execution error.

Public Interfaces

KafkaStreams.java

/**
     * Attempts to shutdown an application.
     * If there is an alive StreamThread it will succeed, if there is not it will fail
     *
     * @return Will return true if shutdown is initiated false if it is not possible.
     */
    public boolean initiateClosingAllClients();


Proposed Changes

We propose to add a new method that will cause all clients in the application to be shutdown when called. We achieve this adding initiateClosingAllClients to `KafkaStreams.java`  which will search for an alive stream thread to start the shutdown. If there is not an alive thread the method will return false indicating that the shutdown was not initiated. The method will be non-blocking but will stop the alive thread it found from processing.

In order to communicate the shutdown request from one client to the others we propose to update the SubcriptionInfoData to include a short field which will encode an error code. The error will be propagated through the metadata during a rejoin event via the assignor. The actual shutdown will be handled by the StreamsRebalnceListener, this is where the INCOMPLETE_SOURCE_TOPIC_METADATA error can also be handled.



Compatibility, Deprecation, and Migration Plan

The SubcriptionInfoData will be upgraded to version 8 because we are adding a field for an error code to be propagated through the application.

No methods need to be deprecated.

Rejected Alternatives

  • Two paths, Internal Error via exception and a request method for users to call
  • Add a config option to shutdown when ever a user error is thrown - no flexible enough
  • Throwing an Exception instead of shutdown Application
  • No labels