Skip to content

Hono does not recover from some Kafka Exceptions #3682

@WatcherWhale

Description

@WatcherWhale

We see that if Hono encountes a Kafka AuthenticationException, it does not try to re-connect to the Kafka brokers and stops sending messages to any topic. This is a similar issue as #3544.

It seems Hono does not consider an AuthenticationException as a fatal error, which causes the cached producer to not be closed:

public static boolean isFatalError(final Throwable error) {
return error instanceof ProducerFencedException
|| error instanceof OutOfOrderSequenceException
|| error instanceof AuthorizationException
|| error instanceof UnsupportedVersionException
|| error instanceof UnsupportedForMessageFormatException;
}

If we apply the following patch to Hono we see it does correctly recover from such an exception:

    public static boolean isFatalError(final Throwable error) {
        return error instanceof ProducerFencedException
                || error instanceof OutOfOrderSequenceException
                || error instanceof AuthorizationException
+               || error instanceof AuthenticationException
                || error instanceof UnsupportedVersionException
                || error instanceof UnsupportedForMessageFormatException;
    }
  • Are there any other Exceptions that should close the cached producer?
  • Maybe we should just exclude exceptions that are non-fatal instead of determining what is fatal. If Kafka ever adds another fatal exception, some unexpected dangerous behavior could occur.
  • Like stated hono constantly fails to publish messages to the kafka broker without being able to recover #3544, there are maybe other ways to determine if a cached producer needs to be closed. Like consecutive number of message that could not be produced, ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions