KIP-848 migration guide says never use assign()/unassign() with group.protocol='consumer'; it's only rejected after subscribe

オープン 初心者向け
#2,405 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@hidingmyname がすでに取り組んでいます。

2026年10月29日 から。

  • #2407 @hidingmyname による — オープン

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
kafka, python
領域
documentation

調査の方向性

docs/kip-848-migration-guide.md の「Rebalance Callback Changes」セクションと、docs/kip-848-migration-guide.rst の対応するセクションから始めます。記述を、issue で説明されている動作と .NET ガイドの「Manual partition assignment」セクションと比較します。両方の Python ガイドで、subscribe する前の manual assign() がサポートされていることを明確にし、subscribe した後の制限を説明できていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Description

docs/kip-848-migration-guide.md, section "Rebalance Callback Changes":

- **Do not** use `consumer.assign()` or `consumer.unassign()` when using `group.protocol='consumer'` (KIP-848).

docs/kip-848-migration-guide.rst has the same text:

-  **Do not** use ``consumer.assign()`` or ``consumer.unassign()`` when
   using ``group.protocol='consumer'`` (KIP-848).

This is broader than what the client actually enforces. In librdkafka, the
check that rejects a non-incremental assign ("Changes to the current
assignment must be made using incremental_assign() or incremental_unassign()
when rebalance protocol type is COOPERATIVE") only applies once the rebalance
protocol is COOPERATIVE. With the consumer protocol, that only happens
after the consumer has subscribed. Before that, rd_kafka_cgrp_rebalance_protocol()
returns NONE:

if (rkcg->rkcg_group_protocol == RD_KAFKA_GROUP_PROTOCOL_CONSUMER) {
        if (!(rkcg->rkcg_consumer_flags &
              RD_KAFKA_CGRP_CONSUMER_F_SUBSCRIBED_ONCE))
                return RD_KAFKA_REBALANCE_PROTOCOL_NONE;

        return RD_KAFKA_REBALANCE_PROTOCOL_COOPERATIVE;
}

So consumer.assign() for manual partition assignment, without calling
subscribe(), still works with group.protocol='consumer'.

Why it matters

Applications that use manual assignment, often with a group.id set only for
committing offsets, read this guide to decide whether they can switch
group.protocol. As written, the guide tells them they can't use assign()
at all, which isn't true. The restriction that actually matters, using only
incremental_assign()/incremental_unassign() once subscribed, gets lost
in the over-broad wording.

Suggested fix
-- **Do not** use `consumer.assign()` or `consumer.unassign()` when using `group.protocol='consumer'` (KIP-848).
+- **Do not** use `consumer.assign()` or `consumer.unassign()` after subscribing with `group.protocol='consumer'` (KIP-848).
+  `consumer.assign()` can still be used for manual partition assignment without subscribing.

and the same change in docs/kip-848-migration-guide.rst:

--  **Do not** use ``consumer.assign()`` or ``consumer.unassign()`` when
-   using ``group.protocol='consumer'`` (KIP-848).
+-  **Do not** use ``consumer.assign()`` or ``consumer.unassign()`` after
+   subscribing with ``group.protocol='consumer'`` (KIP-848).
+   ``consumer.assign()`` can still be used for manual partition assignment
+   without subscribing.
Upstream reference

confluent-kafka-go fixed the same sentence in its copy of this guide in
confluentinc/confluent-kafka-go@cc3d3f7 ("Few minor nits", 2025-10-10):

--- a/kafka/kip-848-migration-guide.md
+++ b/kafka/kip-848-migration-guide.md
@@ -51,15 +51,15 @@
 - In the **rebalance callbacks**, you **must only use** (optional - if not used, client will handle it internally):
   - `consumer.IncrementalAssign(e.Partitions)` to assign new partitions
   - `consumer.IncrementalUnassign(e.Partitions)` to revoke partitions
-- **Do not** use `consumer.Assign()` or `consumer.Unassign()` when using `group.protocol='consumer'` (KIP-848).
+- **Do not** use `consumer.Assign()` or `consumer.Unassign()` after subscribing with `group.protocol='consumer'` (KIP-848).

The .NET guide (doc/kip-848-migration-guide.md) already describes it
correctly in its "Manual partition assignment" section: "You can still use
Assign() before being subscribed but after subscribing you can only use
IncrementalAssign() and IncrementalUnassign()." All three clients use
the same librdkafka check, so the Python guide can use the same wording.

I can submit a PR for this.

主要言語
Python
スター
528
フォーク
977
平均マージ
2日 19時間
マージ済み PR(30日)
19

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

confluentinc/confluent-kafka-python のほかの issue

confluentinc/confluent-kafka-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。