Repository navigation
Set auto.offset.reset=earliest by default not to lost messages - #281
Conversation
| if (props.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG) == null) { | ||
| props.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); | ||
| } |
There was a problem hiding this comment.
main change is only here
There was a problem hiding this comment.
this explains why we set auto.offset.reset=earliest by default, and how to override config by users who understand the risks
| |Unlimited | ||
|
|
||
| |Any positive number | ||
| |1 to 1,000,000 |
There was a problem hiding this comment.
(unrelated to this change) document is not correct. Actually the max is 1,000,000
ocadaruma
left a comment
There was a problem hiding this comment.
Thanks!
The change makes sence. Left some comments
| === Adding partitions | ||
|
|
||
| Producers can start producing tasks to new partitions before processors get them assigned. | ||
| With `latest`, tasks produced in between are skipped. |
There was a problem hiding this comment.
There was a problem hiding this comment.
now it's added, thank you!
|
|
||
| === Restarting after committed offsets expired | ||
|
|
||
| If all processors of a consumer group are stopped longer than the offset retention of your Kafka cluster (`offsets.retention.minutes`, 7 days by default), the committed offsets expire. |
There was a problem hiding this comment.
[nits] better "offsets.retention.minutes, 7 days by default as of kafka 3.9", because this may change in the future
There was a problem hiding this comment.
Thank you, now all default values in the page have "as of Apache Kafka 4.3"!
| These topics receive tasks only when tasks are retried or shaped, and Decaton commits offsets only for processed tasks, so their partitions can stay without committed offsets for a long time. | ||
| For example, a partition of the retry topic has no committed offset until a retried task on it is processed for the first time. | ||
|
|
||
| If such a partition is reassigned before the task on it is processed, the task is skipped with `latest`. |
There was a problem hiding this comment.
1. nits: reassign -> rebalance
I prefer word "rebalance", because reassign sounds like the broker-side data movement.
2. clarify the situation
This alone sounds a bit confusing, because this sounds like partition rebalance always cause message loss.
WDYT:
Combining with the fact task retry often happens during partition rebalance (because during rebalance, process may become unstable temporarily), it may lead to subtle delivery-loss issue.
There was a problem hiding this comment.
I haven't managed the broker, so I hadn't considered that perspective. Thank you!
| This typically happens during a deployment: a task is retried, and the rebalance reassigns the partition while the retried task is waiting for its backoff. | ||
| With `latest`, a retried or shaped task on such a partition is skipped if a rebalance happens before the task is processed. | ||
| Tasks are often retried during a rebalance because processing can become unstable temporarily (e.g. during a deployment). | ||
| A retried task also waits for its backoff before being processed, so this can lead to subtle delivery loss. |
There was a problem hiding this comment.
Ah- good point. Now I get why retry-task is problematic in this scenario.
Resolve #280
Kafka's default value for
auto.offset.resetislatest, but this can cause message loss when adding partitions or when using retry/shaping topics for the first time.I don't think every Decaton user, especially users of retry or shaping, should have to remember to explicitly set
auto.offset.reset=earliestin user code. If users configure retries, their intention is usually to process those messages reliably.It would be unfortunate to lose messages because of missing Kafka-specific knowledge rather than an issue with Decaton itself, so I'd like Decaton to provide a safer default.
There is of course a trade-off.
latestis still appropriate for some use cases, and ultimately this should remain configurable by users.This change is a breaking change in Decaton and changes the default to
auto.offset.reset=earliest. Users can still explicitly selectlatestif that is what they want.Users who do not want this new default can set
latestthroughconsumerConfig, as described in the guide.