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

Rebalance can leave some workers with no partitions #93

Open
2 tasks done
bobh66 opened this issue Feb 4, 2021 · 5 comments
Open
2 tasks done

Rebalance can leave some workers with no partitions #93

bobh66 opened this issue Feb 4, 2021 · 5 comments

Comments

@bobh66
Copy link
Contributor

bobh66 commented Feb 4, 2021

Checklist

  • I have included information about relevant versions
  • I have verified that the issue persists when using the master branch of Faust.

Steps to reproduce

When the number of partitions for an agent topic is not evenly divisible by the number of workers, the PartitionAssignor can leave one or more workers with no partitions assigned. This wastes CPU and memory resources, as well as causing other workers to carry a heavier load and potentially reduces throughput.

The initial deployment will distribute the partitions across all workers. For example, a topic with 100 partitions will be spread across 40 workers with 20 workers having three partitions and 20 workers having 2 partitions. The CopartitionedAssignor will calculate the (maximum) capacity for each worker to be 3 partitions, using the formula ceil(num_partitions / num_workers).

Now if one worker gets rebooted or leaves the group for any reason, a rebalance is triggered and the 2 or 3 partitions for that worker get moved to other workers that have 2 partitions, leaving 22 or 23 workers with 3 partitions and 17 or 18 workers with 2 partitions (100 partitions across 39 workers).

When the rebooted worker recovers and rejoins the group, it will probably not receive any partitions because there are no "extra" partitions on any of the workers. The maximum capacity is still 3, no worker has more than 3 partitions, so no partitions are "available" for assignment. Rebooting the worker has no impact for the same reason.

The worker with no partitions will leave the consumer group after 5 minutes as the aiokafka Fetcher has been idle due to no assignment, which means that future rebalances of the group will NOT include this consumer/worker, and it will be idle forever, or until the group is redeployed.

Expected behavior

Partitions should be assigned to all available workers, as balanced as possible.

Actual behavior

Workers can receive no partition assignment and leave the group.

Full traceback

Paste the full traceback (if there is any)

Versions

  • Python version - 3.7
  • Faust version - 0.4.6
  • Operating system - Centos
  • Kafka version N/A
  • RocksDB version (if applicable) N/A
bobh66 added a commit to bobh66/faust-1 that referenced this issue Feb 4, 2021
bobh66 added a commit to bobh66/faust-1 that referenced this issue Feb 4, 2021
patkivikram pushed a commit that referenced this issue Feb 5, 2021
* fix partition assignment issues (#93) and commit exceptions (#94)

* fix partition assignment issues (#93) and commit exceptions (#94)

* fix black formatting

* fix unused variable in test

* fix unit test

* fix unused import

* revert partition assignor changes
@jkgenser
Copy link

jkgenser commented Feb 7, 2021

@bobh66 : Just wondering, why did you revert your changes to fix the partition assignment problems raised in this issue?

@bobh66
Copy link
Contributor Author

bobh66 commented Feb 7, 2021

Hi @jkgenser - I needed to do more testing with the partition assignment changes and I didn't want to hold up releasing the other two fixes which are also important. The existing partitioner logic will intentionally leave a consumer without any active partitions, which is also validated by existing tests, so in order to "fix" that I need to change the way the tests work. I'm reluctant to make too big a change in this area given how much of an impact it can have. I'm going to restrict the partitioner changes to only force a "balanced" configuration when there are no tables in use and the table_standby_replicas option is set to 0. That will limit the initial impact of the change so we can see how it works, and then decide whether to expand the implementation or not. Since the partitioner will default to promoting a standby partition to active, it is still possible to have empty assignments even with my changes, so it's better to leave that code alone for now. Hopefully this makes sense.

bobh66 added a commit to bobh66/faust-1 that referenced this issue Feb 8, 2021
bobh66 added a commit to bobh66/faust-1 that referenced this issue Feb 9, 2021
patkivikram added a commit that referenced this issue Feb 10, 2021
* improve partition assignment balance (#93)

* restrict partition balancing logic (#93)

Co-authored-by: Vikram Patki <54442035+patkivikram@users.noreply.github.com>
@taybin
Copy link
Contributor

taybin commented May 3, 2021

Has this issue been resolved?

@xaralis
Copy link

xaralis commented Oct 8, 2021

Has this issue been resolved?

@taybin We're currently experiencing this so I guess this isn't resolved yet.

@bobh66
Copy link
Contributor Author

bobh66 commented Oct 8, 2021

At this point there will always be scenarios where this can happen - see this comment for more details on exactly what was fixed - #97 (comment)

Basically you need to "enable" the fix by setting table_standby_replicas to 0.

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

No branches or pull requests

4 participants