Skip to content

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

Merged
Milind L (milindl) merged 15 commits intomasterfrom
dev_kip_881_range_assignor
Jun 10, 2023
Merged

[consumer] Add rack-awareness (KIP-881) to assignors#4252
Milind L (milindl) merged 15 commits intomasterfrom
dev_kip_881_range_assignor

Conversation

@milindl
Copy link
Copy Markdown
Contributor

@milindl Milind L (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
Copy Markdown
Contributor Author

Rebased onto latest protocol changes.

@milindl Milind L (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 Milind L (milindl) changed the title [consumer] Add rack-awareness (KIP-881) to range assignor [consumer] Add rack-awareness (KIP-881) to assignors May 18, 2023
@neuralspin
Copy link
Copy Markdown

It would be a great change!

Comment thread src/rdkafka_broker.c Outdated
Comment thread src/rdkafka_assignor.c
Comment thread src/rdkafka_range_assignor.c Outdated
Milind L (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 <[email protected]>
Co-authored-by: William Morgan <[email protected]>
Co-authored-by: William Morgan <[email protected]>
@milindl Milind L (milindl) force-pushed the dev_kip_881_range_assignor branch from 3d3efe6 to fb2c94f Compare June 5, 2023 09:12
Comment thread src/rdkafka_metadata.c Outdated
Comment thread CHANGELOG.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Amazing job Milind L (@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.

3 participants