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

[consumer] Add rack-awareness (KIP-881) to assignors #4252

Merged
merged 15 commits into from Jun 10, 2023

Conversation

milindl
Copy link
Contributor

@milindl milindl commented Apr 13, 2023

This builds on the protocol change PR to add rack awareness to the Range Assignor.

I understand that this is quite a large PR, here are the main changes:

  1. rd_kafka_range_assignor_assign_cb and its call to rd_kafka_topic_assignment_state_new form the entry points of the assignment algorithm, and should probably be seen first. The code is based on the AK RangeAssignor.java and it is recommended to keep that open.
  2. Unit test related changes, some stuff from sticky_assignor was moved to common files, because it was reused in range assignor. Earlier, rdkafka_range_assignor.c did not have any unit tests (there were some, but in rdkafka_assignor.c).
  3. Unit tests from the Java range assignor. The entry point for this is rd_kafka_range_assignor_unittest. Almost all the tests within RangeAssignorTest.java have been converted, except a few.

For sticky assignor:

  1. Start with rd_kafka_sticky_assignor_assign_cb. They match, almost completely, with the Java changes to AbstractStickyAssignor.java in this PR.. Additionally, a struct matching RackInfo in the Java implementation, is added.

  2. There are, what I think are two pre-existing bugs in the implementation that I found while porting tests. They are marked in the commit itself as a comment (I will remove the comment after first round of reviews).

  3. Unit test addition: tests missing or different from AbstractStickyAssignorTest.java are added, existing tests are parametrized to include rack cases (rack consumer, rack brokers, rack both).

  4. Some refactoring of common functions across assignors and unit tests into rdkafka_assignor.h/c to avoid duplication.

@milindl
Copy link
Contributor Author

milindl commented May 16, 2023

Rebased onto latest protocol changes.

@milindl milindl force-pushed the dev_kip_881_range_assignor branch from 3f50a9d to b10cf3d Compare May 16, 2023 09:59
Base automatically changed from dev_kip881_all_protocol_changes to master May 16, 2023 14:14
@milindl milindl changed the title [consumer] Add rack-awareness (KIP-881) to range assignor [consumer] Add rack-awareness (KIP-881) to assignors May 18, 2023
@ZhukovAntonPls
Copy link

It would be a great change!

src/rdkafka_broker.c Outdated Show resolved Hide resolved
src/rdkafka_assignor.c Show resolved Hide resolved
src/rdkafka_range_assignor.c Outdated Show resolved Hide resolved
milindl and others added 9 commits June 5, 2023 14:42
* [cooperative][manual commit] Prevent offsets from being committed when a rebalance is in progress and partitions are owned by consumer

* Add test

* Format

* Ensure the operation is thread safe

* Add missing test config

* Don't propagate results if we decide to skip committing

* fixing broken test

* fixing typo

* Add rack-awareness (KIP-881) to sticky-assignor

* Fix minor issues with commiting only when not rebalancing

* memory leak in test
* test naming
* test copyright

* Fix style and remove rd_list_add_const

---------

Co-authored-by: Roxane Fruytier <roxane.fruytier@datadoghq.com>
Co-authored-by: William Morgan <william.morgan@crowdstrike.com>
Co-authored-by: William Morgan <wmorgan6796@gmail.com>
@milindl milindl force-pushed the dev_kip_881_range_assignor branch from 3d3efe6 to fb2c94f Compare June 5, 2023 09:12
src/rdkafka_metadata.c Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@milindl milindl force-pushed the dev_kip_881_range_assignor branch from 3f06e7a to 8a31959 Compare June 8, 2023 03:38
@milindl milindl requested a review from emasab June 8, 2023 05:13
Copy link
Collaborator

@emasab emasab left a comment

Choose a reason for hiding this comment

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

LGTM! Amazing job @milindl !

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