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

Aperta Adatta ai principianti
#2,405 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@hidingmyname ci sta già lavorando.

Dal 29/10/2026.

  • #2407 di @hidingmyname — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
kafka, python
Ambito
documentation

Direzione di ricerca

Inizia dalla sezione «Rebalance Callback Changes» in docs/kip-848-migration-guide.md e dalla sezione corrispondente in docs/kip-848-migration-guide.rst. Confronta la formulazione con il comportamento descritto nell’issue e con la sezione «Manual partition assignment» della guida .NET. Il lavoro è completato quando entrambe le guide Python chiariscono che manual assign() è supportato prima della sottoscrizione e descrivono la restrizione dopo la sottoscrizione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
528
Fork
977
Merge medio
2g 19h
PR unite (30g)
19

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di confluentinc/confluent-kafka-python

Tutte le issue di confluentinc/confluent-kafka-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.