Versions Compared

Key

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

Table of Contents

This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own descriptionKIP is aimed at improving the error-handling semantics in Kafka Streams when Kafka Steams fails to serialize a message to the downstream sink by providing an interface that can provide custom messaging of the error (e.g. report to a custom metrics system) and indicate to Streams whether or not it should re-throw the Exception, thus causing the application to fall over.

Status

Current state: "Under Discussion" Accepted

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]

JIRA: KAFKA-7499

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

...

We are proposing addition of a new overloaded method in ProductionExceptionHandler interface, handle handleSerializationException, that has the following signature:

        ProductionExceptionHandlerResponse handleSerializationException(ProducerRecord record, Exception exception);     

To accept different types of records from multiple topologies, ProducerRecord is defined without generics. The above interface method will have a default implementation which returns ProductionExceptionHandlerResponse.FAIL

Proposed Changes

This implementation will override the new method, handleSerializationException, in the following class:

  • AlwaysContinueProductionExceptionHandler and returns response as CONTINUE
  • No need to implement in DefaultProductionExceptionHandler, as the response is set to FAIL by default.

We'll implement the following error handling logic to the send in RecordCollectorImpl. The new method, handleSerializationException, in ProductionExceptionHandler will not be invoked for

  1. ClassCastException is thrown while serializing record key / value. We will continue to throw this exception and not invoke the new method.  This will allow the current behavior to continue as this can help identify misconfigured serdes 

It will be invoked for

  1. Any other unchecked exceptions, that thrown during record key / value serialization.
    1. If the result is CONTINUE, log a note at WARN that we received that result and are not failing Streams as a result.
    2. If the result is FAIL, log a message at ERROR that we received that result and set sendException so Streams will fail.

Earlier, we are invoking the error handler only when there are any exceptions in producer callback. Now, we also invoke the handler when hitting the serialization exception. As explained in KIP-210, this will facilitate a number of error handling scenarios.  Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
  • If we are changing behavior how will we phase out the older behavior?
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Rejected Alternatives

...

The default behavior will be consistent with the existing behavior. The new method, handleSerializationException, will have a implementation that is set to FAIL by default.

Rejected Alternatives

We have considered to reuse the existing handle(ProducerRecord<byte[], byte[]> record, Exception exception) method in ProductionExceptionHandler, but it has the following limitation:

  1. The parameter ProducerRecord key and value type is set to byte[], on hitting the serialization exception the record key and value type may not be byte[].