Skip to content

fix: transition idempotent producer to UNINITIALIZED in reset_producer_id (#3181) - #3182

Merged
dpkp merged 1 commit into
dpkp:masterfrom
zerafachris:fix/idempotent-reset-producer-id-3181
Nov 4, 2026
Merged

dpkp merged 1 commit into
dpkp:masterfrom
zerafachris:fix/idempotent-reset-producer-id-3181

Conversation

@zerafachris

Copy link
Copy Markdown
Contributor

Fixes #3181

Root Cause

Since init_producer_id() was updated to drive non-transactional idempotent producers through UNINITIALIZED -> INITIALIZING -> READY, calling reset_producer_id() (when an in-retry batch expires or a pre-KIP-360 sequence error requires a producer ID reset) cleared producer_id_and_epoch to (-1, -1) while leaving _current_state at TransactionState.READY. On subsequent sender iterations, init_producer_id() returned early because _current_state != TransactionState.UNINITIALIZED, leaving the producer without a valid producer ID indefinitely.

Changes

  • Allow TransactionState transitions to UNINITIALIZED from UNINITIALIZED and READY in TransactionState.is_transition_valid.
  • Transition _current_state back to TransactionState.UNINITIALIZED in TransactionManager.reset_producer_id() so the next init_producer_id() call requests a fresh producer ID and epoch from the broker.
  • Add test_idempotent_producer_init_then_reset_then_reinit in test/producer/test_transaction_manager_mock_broker.py verifying the full init -> READY -> reset -> UNINITIALIZED -> re-init -> READY cycle.

Test Evidence

  • pytest test/producer/test_transaction_manager.py test/producer/test_sender.py test/producer/test_transaction_manager_mock_broker.py test/producer/test_producer.py (255 passed)

Prepared with AI assistance (OpenCode), reviewed for correctness before submission.

@hly0025

hly0025 commented Nov 3, 2026

Copy link
Copy Markdown

I took a look at the above. Here is what was done: applied proposed change to 3.0.12 the outage test in #3181 recovered (5 of 5 messages delivered with a new producer ID)

@dpkp

dpkp commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks!

@dpkp
dpkp merged commit 6d97687 into dpkp:master Nov 4, 2026
20 checks passed
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.

Idempotent producer never sends again after a retried batch expires (reset_producer_id() leaves ID at -1/-1)

3 participants