Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronous partition assignment handler (internal) #761

Merged
merged 2 commits into from Jul 25, 2019

Conversation

ennru
Copy link
Member

@ennru ennru commented Mar 29, 2019

Purpose

For now this PR just introduces the synchronous partition assignment handler internally without a user-facing API as the use-cases for this need to be understood better.

Introduce a new callback for changes in partitions assigned to an Alpakka Kafka consumer. This allows executing code before a rebalance continues, and querying the underlying Kafka consumer.

These callbacks are much more powerful (and dangerous) than the current rebalance listener actor. The callbacks are executed on the same thread that called poll() (the actor thread) so they are allowed to call into the Kafka consumer eg. to query current offsets, commit offsets or to seek to an offset position. The callbacks add to the time poll() is executed and block the internal Kafka consumer actor from doing any other work. As this can easily make influence other Kafka consumer actors running on the same dispatcher, the time the callbacks take is checked and warnings are issued to the logs if they pass a configurable threshold.

This allows for new ways to handle offsets which might show more efficient for certain use-cases. The tests show an example for external offset storage and one example which commits on rebalance only.

Background Context

It has been discussed in #539 that the lack of blocking user-defined call-backs to react on Kafka's partition rebalancing makes certain use cases impossible with Alpakka Kafka.

In particular, it is impossible to combine Kafka's partition assignment with external offset storage.

References

References #539
Follow up #841

@ennru ennru changed the title Synchronous partition assignment handler WIP: Synchronous partition assignment handler Mar 29, 2019
@seglo
Copy link
Member

seglo commented Mar 30, 2019

This looks really promising @ennru . When I was considering an API I was thinking about providing strategies that users could opt in with (i.e. "commit on revoked partitions"), and then provide a super user interface which just exposed the consumer itself, but I like the idea behind RestrictedConsumer better.

build.sbt Show resolved Hide resolved
@2m
Copy link
Member

2m commented Jun 26, 2019

Looking good. I like how TransactionalSource was able to use this without any code changes.

@ennru
Copy link
Member Author

ennru commented Jul 2, 2019

For now, I removed the user-facing API so that the new partition assignment handler is used internally, only.
The plan is to continue to explore the scenarios this kind of partition assignment handler improves as eg. #841 and #843

@ennru ennru changed the title WIP: Synchronous partition assignment handler Synchronous partition assignment handler (internal) Jul 2, 2019
@2m 2m force-pushed the synchronous-partition-handling branch from 606825d to 6ca20b6 Compare July 24, 2019 13:22
Copy link
Member

@2m 2m left a comment

Choose a reason for hiding this comment

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

LGTM

@2m 2m force-pushed the synchronous-partition-handling branch from 6ca20b6 to 13d015b Compare July 25, 2019 07:01
@2m 2m merged commit 220022c into akka:master Jul 25, 2019
@ennru ennru deleted the synchronous-partition-handling branch October 21, 2019 08:48
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.

None yet

3 participants