Table of Contents |
---|
Status
Current state: "Under Discussion"
...
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
Currently when a user sends a null key to a log compacted topic, the broker returns CorruptRecordException
, which is a retriable exception. As such, the producer keeps retrying until retries are exhausted or request.timeout.ms expires and eventually throws a TimeoutException
. This is confusing and not user-friendly.
The broker should throw a non-retriable exception with a message explaining the error.
New or Changed Public Interfaces
This KIP introduces a new error type INVALID_
COMPACTION
_KEY
.
It introduces a new non-retriable exception InvalidCompactionKeyException
InvalidRecordKeyException
. Going forward user request will fail without doing retries, if they try to produce to a log compacted topic with a null key.
Proposed Changes
Add a new error code and exception as follows :
Error Code :
INVALID_COMPACTIONRECORD_KEY
(45, new InvalidCompactionKeyException
InvalidRecordKeyException
("Message key cannot be null for a log compacted topicis invalid."))
Exception :
Code Block | ||
---|---|---|
| ||
public class InvalidCompactionKeyExceptionInvalidRecordKeyException extends ApiException { private static final long serialVersionUID = 1L; public InvalidCompactionKeyExceptionInvalidRecordKeyException() { super(); } public InvalidCompactionKeyExceptionInvalidRecordKeyException(String message, Throwable cause) { super(message, cause); } public InvalidCompactionKeyExceptionInvalidRecordKeyException(String message) { super(message); } public InvalidMessageKeyExceptionInvalidRecordKeyException(Throwable cause) { super(cause); } } |
Compatibility, Deprecation, and Migration Plan
We
...
will only return this exception for ProduceRequest V3 or higher. The older version of ProduceRequest will still get the CorruptRecordException.