Skip to content

Set auto.offset.reset=earliest by default not to lost messages - #281

Open
Yang-33 wants to merge 5 commits into
line:masterfrom
Yang-33:default-earliest
Open

Yang-33 wants to merge 5 commits into
line:masterfrom
Yang-33:default-earliest

Conversation

@Yang-33

@Yang-33 Yang-33 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Resolve #280

Kafka's default value for auto.offset.reset is latest, 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=earliest in 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. latest is 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 select latest if that is what they want.

Users who do not want this new default can set latest through consumerConfig, as described in the guide.

@Yang-33 Yang-33 added the breaking change Breaking change for a public API label Oct 8, 2026
Comment on lines +70 to +72
if (props.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG) == null) {
props.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main change is only here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this explains why we set auto.offset.reset=earliest by default, and how to override config by users who understand the risks

Comment thread docs/rate-limiting.adoc
|Unlimited

|Any positive number
|1 to 1,000,000

@Yang-33 Yang-33 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* <li>(0, 1,000,000]: Do the best to process tasks as much as N per second.
* N may not be kept well if a task takes over a second to process or N is greater than
* actual throughput per second.</li>
* <li>0: Stop all processing but the task currently being processed isn`t interrupted</li>
* <li>-1: Unlimited</li>
* </ul>
* <p>
* See also {@link RateLimiter}.
* <p>
* Reloadable: yes
*/
public static final PropertyDefinition<Long> CONFIG_PROCESSING_RATE =
PropertyDefinition.define("decaton.processing.rate.per.partition", Long.class,
RateLimiter.UNLIMITED,
v -> v instanceof Long
&& RateLimiter.UNLIMITED <= (long) v
&& (long) v <= RateLimiter.MAX_RATE);

(unrelated to this change) document is not correct. Actually the max is 1,000,000

@Yang-33
Yang-33 marked this pull request as ready for review October 9, 2026 00:03
@Yang-33
Yang-33 requested a review from ocadaruma October 9, 2026 00:15

@ocadaruma ocadaruma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it's added, thank you!

Comment thread docs/auto-offset-reset.adoc Outdated

=== 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits] better "offsets.retention.minutes, 7 days by default as of kafka 3.9", because this may change in the future

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, now all default values in the page have "as of Apache Kafka 4.3"!

Comment thread docs/auto-offset-reset.adoc Outdated
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`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't managed the broker, so I hadn't considered that perspective. Thank you!

@Yang-33
Yang-33 requested a review from ocadaruma October 19, 2026 06:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking change for a public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set auto.offset.reset=earliest by default to rescue lost message for first retry and shaping

2 participants