Skip to content

Retry records delivery in shardConsumer - #1822

Merged
chenylee-aws merged 2 commits into
awslabs:masterfrom
chenylee-aws:handle_exception
Oct 13, 2026
Merged

chenylee-aws merged 2 commits into
awslabs:masterfrom
chenylee-aws:handle_exception

Conversation

@chenylee-aws

@chenylee-aws chenylee-aws commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Description of changes:

Previously, if anything in KCL's data path threw before a batch was handed to processRecords (shard lookup, deaggregation, schema decoding, task execution listener, metrics, etc.), ShardConsumerSubscriber.onNext logged "The incoming data has been skipped" and requested the next batch anyway. The batch was never delivered, and once the application checkpointed a later batch those records were lost for good. Failures inside ProcessTask were also swallowed and reported as a completed task, and at shard end the exception was discarded entirely.

With this change, the handoff to the record processor is the only thing that advances the read position. Every failure in KCL's own handling of a batch now leads to either redelivery or a halted shard consumer with the error surfaced:

  • Exceptions before the handoff: ProcessTask rethrows instead of swallowing, and the subscriber retries the same batch in place with exponential backoff (500 ms to 10 s). Ordering is preserved, because the next batch is not requested until the current one is handed off. lastAccepted and request(1) only advance after a successful handoff.
  • Errors (OOM, linkage errors, etc.): not retried. The subscriber stops without advancing, and the error is recorded in dispatchFailure, which healthCheck rethrows on the Scheduler thread, as before.
  • Shutdown or interrupt during retry: retrying stops. The batch was never delivered and is reprocessed from the last checkpoint by the next lease owner.
  • Exceptions from the application's processRecords: unchanged. They are logged and the batch is skipped.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@chenylee-aws
chenylee-aws merged commit 2a011af into awslabs:master Oct 13, 2026
7 of 9 checks passed
@chenylee-aws
chenylee-aws deleted the handle_exception branch October 13, 2026 23:17
vincentvilo-aws pushed a commit to vincentvilo-aws/amazon-kinesis-client that referenced this pull request Oct 26, 2026
chenylee-aws added a commit to chenylee-aws/amazon-kinesis-client that referenced this pull request Oct 26, 2026

This branch is waiting to be deployed

1 waiting deployment
manual-approval β€” 6aaed4a8 Waiting Oct 12, 2026 by chenylee-aws via wait-for-approval #344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants