Skip to content

Commit de5761f

Browse files
dpkpclaude
andauthored
Update changelog (#3035)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 65113cf commit de5761f

2 files changed

Lines changed: 666 additions & 52 deletions

File tree

CHANGES.md

Lines changed: 306 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,339 @@
11
# 3.0.0 (Unreleased)
22

3-
Breaking Changes
4-
* Drop python2 support (#2699, #2774, #2837)
3+
This is a major release with significant changes to kafka-python internals to simplify networking and feature development. It introduces a new networking layer (`kafka.net`) and a dynamic protocol system that uses JSON schema files imported from Apache Kafka. It substantially refactors and expands the Admin client, including breaking changes to some API signatures, and it lands a long list of KIP features/changes across the producer, consumer, admin, and networking/metadata clients. Protocol support across kafka-python is now at or beyond the apache kafka 3.0 baseline.
4+
5+
## Breaking Changes
6+
7+
### Python Compatibility
8+
* Drop python2 support (#2699, #2774, #2837, #2846)
9+
10+
### Default Configuration Changes
11+
* KIP-679: Update Producer defaults -- enable_idempotence=True, acks='all' (#3013)
12+
* KIP-735: Increase default consumer session_timeout_ms from 10s to 45s (#3030)
13+
* Rename api_version_auto_timeout_ms -> bootstrap_timeout_ms; default 30s (#3028)
14+
15+
### Admin API Changes
16+
* Admin: change response shapes to simple dicts (#2883)
17+
* Admin: groups apis renames; add offsets, members apis (#2892)
18+
* Admin: Deprecate NewTopics/NewPartitions in favor of simple dicts (#2869)
19+
20+
### Consumer API Changes
521
* Consumer: use assignor instances, not classes (#2775)
622

7-
Protocol
23+
### Error Hierarchy
24+
* KafkaError subclass Exception not RuntimeError (#2932)
25+
* Make IncompatibleBrokerVersion a subclass of UnsupportedVersionError (#2924)
26+
* Eliminate NoBrokersAvailableError (#2942)
27+
* KafkaProtocolError is not retriable (#2941)
28+
29+
### Old Networking Stack Removal
30+
* Remove kafka.client_async / kafka.conn legacy modules (#2918)
31+
* Drop version probes for pre-0.10/ApiVersionsRequest brokers
32+
33+
## Networking (kafka.net)
34+
35+
Complete refactor of the networking layer using a bespoke event-loop supporting async/await (but no asyncio yet). All three clients (Admin, Consumer, Producer) use a dedicated IO thread that drives a selector-based event loop. AdminClient/KafkaConsumer leverage a built-in io thread supplied by kafka.net, KafkaProducer continues to use its existing background Sender thread for now.
36+
37+
### Async IO Substrate
38+
* kafka.net: Refactored async networking modules (generator-based coroutines) (#2812)
39+
* kafka.net: Network IO thread (#2965, #2980, #2961, #2968, #2963)
40+
* KafkaNetClient: drop-in replacement for KafkaClient using kafka.net (#2816)
41+
* KafkaNetSocket: interface class for socket and proxy connections (#2992)
42+
* kafka.net.manager: Add call_soon(coro) and run(coro) for sync/async bridge (#2862)
43+
* kafka.net.manager: Bootstrap is sync/blocking (#2919)
44+
* connection: short-circuit send/recv when closed (#2967)
45+
46+
### Transports and Proxies
47+
* Default SSLContext -> PROTOCOL_TLS_CLIENT; minimum version TLS 1.2 (#2807)
48+
* Enable TCP KeepAlive as default socket option (#2904)
49+
* kafka.net: HTTP CONNECT proxy support (RFC 7231 s4.3.6) (#2990)
50+
51+
### SASL Authentication
52+
* kafka.net: Validate SASL/SCRAM iterations (#3026)
53+
* SASL: Prefer node hostname to IP address when building mechanisms (#3003)
54+
55+
### Timeouts and Connection Management
56+
Per-request and per-stage timeouts replace the old single client-wide timeout.
57+
* KIP-601: support socket_connection_setup_timeout_ms w/ exponential backoff (#3027)
58+
* kafka.net: Bootstrap if needed for metadata refresh (#2825)
59+
* kafka.net: Raise UnknownBrokerIdError when connection fails because node_id is not in metadata (#2876)
60+
61+
### Futures and Wakeups
62+
The `Future` primitive gains `__await__` and a faster slotted implementation; cross-thread wakeups are factored out into a reusable helper.
63+
* Future.__await__ support (#2811)
64+
* Future: __slots__ and callback/errback inlining optimization (#2848)
65+
* Future: clear callbacks/errbacks when done to avoid reference cycles (#2891)
66+
* WakeupNotifier primitive for cross-thread/task wakeups (#2925, #2933)
67+
68+
### Concurrency and Error Handling
69+
Defensive checks throughout the kafka.net event loop and transport stack: improved socket I/O error handling, RuntimeErrors on misuse of the IO thread, and lock-based detection of concurrent access.
70+
* kafka.net.selector: Break scheduled heapq ties when tasks share scheduled_at (#3007)
71+
* kafka.net.selector: Monitor slow tasks with slow_task_threshold_secs (#2946)
72+
* kafka.net.selector: Use threading.Lock() to detect concurrent access to poll() (#2945)
73+
* kafka.net.selector: Track pending tasks to prevent gc before completion (#2950)
74+
* kafka.net.selector: Support reschedule(when, task); idempotent unschedule (#2939)
75+
* kafka.net: Raise RuntimeError on concurrent access to net.poll or wakeup() (#2938)
76+
* kafka.net: Raise RuntimeError on run/call_at/call_soon_threadsafe after closed (#2971)
77+
* kafka.net: Catch unhandled exceptions in IO thread (#2970)
78+
* kafka.net: Improve error handling on sock read/write (#2995)
79+
* kafka.net.transport: Close connection on socket write error (#2973)
80+
* kafka.net: Check locks in _poll_once; add net.drain() (#2949)
81+
82+
## Protocol
83+
84+
A new JSON-schema-based dynamic protocol generator now replaces the legacy hand-written protocol classes (moved to `kafka.protocol.old`).
85+
86+
### Dynamic Protocol Classes
87+
Protocol classes are now generated from the upstream Apache Kafka JSON schemas.
888
* Dynamic protocol classes using upstream json schemas (#2727, #2745, #2779, #2782, #2787, #2810)
989
* Add .pyi type annotation stubs for generated protocol classes (#2784)
10-
* Protocol encode/decode optimization with inline compile/exec (#2785)
11-
* Protocol benchmarks and profiling (make bench-protocol) (#2783)
12-
* Add UUID protocol type (#2703)
13-
* Fix TaggedFields encoding/decoding (#2725)
14-
* Fix VarInt/VarLong encoding (#2706)
1590
* Migrate all internal usage to new protocol classes (#2764, #2765, #2766, #2767, #2768, #2772)
91+
* Refactor treatment of versioned ApiMessage classes (#2739)
92+
* Lookup request header -> response class via ResponseClassRegistry (#2730)
93+
* Manual json schema edits to restore fields dropped in Apache 4.0 (#2738)
94+
95+
### New Types and Messages
96+
* Add UUID protocol type (#2703)
97+
* Add UnsignedInt16 type
98+
* KIP-893: support nullable structs (#2889)
1699
* Replace kafka.structs BrokerMetadata/PartitionMetadata with MetadataResponse structs (#2794)
17100
* Add ConsumerProtocol data schemas (#2754)
18101
* Add StickyAssignorUserData json schema (#2755)
19102

20-
Networking
21-
* kafka.net: Refactored async networking modules (generator-based coroutines) (#2812)
22-
* kafka.net: SSL transport support (#2813)
23-
* kafka.net: SASL authentication support (#2814)
24-
* kafka.net: SOCKS5 proxy support (#2815)
25-
* kafka.net: HTTP CONNECT proxy support (RFC 7231 s4.3.6) (#2990)
26-
* kafka.net: Metrics tracking (#2834)
27-
* KafkaNetClient: drop-in replacement for KafkaClient using kafka.net (#2816)
28-
* Future.__await__ support (#2811)
29-
* Pass task by value when adding call_soon callback to future (#2826)
30-
* Default SSLContext -> PROTOCOL_TLS_CLIENT; minimum version TLS 1.2 (#2807)
103+
### Performance
104+
* Protocol encode/decode optimization with inline compile/exec (#2785)
105+
* Protocol benchmarks and profiling (make bench-protocol) (#2783)
31106

32-
Broker Version Check
107+
### Protocol Fixes
108+
* Fix TaggedFields encoding/decoding (#2725, #2745, #2779)
109+
* Fix VarInt/VarLong encoding (#2706)
110+
* Fix CompactBytes encoding of struct data (#2782)
111+
* Fix compiled encode_into for None arrays (#2790)
112+
* Validate network frame size (#3019)
113+
* Validate DataContainer version (#2759)
114+
115+
### Helpers and Debugging
116+
* DataContainer.to_dict() helper (#2758, #2872, #2879)
117+
* Store in-flight request headers only for protocol parser (#2723)
118+
* Debug log send/recv bytes from protocol parser (#2707)
119+
* Adjust protocol debug logging; add KAFKA_PYTHON_PROTOCOL_DEBUG_LOG (#2719)
120+
121+
## Broker Version Check
122+
123+
Broker version inference is consolidated into a single `BrokerVersionData` helper that tracks the broker's reported API versions and infers a broker version string. `ApiVersionsRequest` is always sent on connect.
124+
125+
### BrokerVersionData
33126
* BrokerVersionData: consolidated version checks (#2795)
34-
* BrokerVersionData: infer up to 4.2 (#2835, #2836)
127+
* BrokerVersionData: infer up to 4.3 (#2835, #2836, #3032)
128+
* BrokerVersionData: support request min/max version (#2868)
129+
* BrokerVersionData: Fix IncompatibleBrokerVersion errors; add __str__ (#2804)
130+
131+
### ApiVersionsRequest
35132
* Always send ApiVersionsRequest on connect (#2802)
36133
* Improve ApiVersionsRequest fallbacks (#2803, #2817, #2821)
37134

38-
Client Bootstrap
135+
## Client Bootstrap
136+
39137
* Fix bootstrap connection error handling (#2831)
40138
* ClusterMetadata: bootstrap_brokers(), set_topics/add_topics/metadata_request (#2805, #2792, #2796, #2797)
41139
* Move bootstrap_brokers fallback from brokers() to least_loaded_node() (#2809)
42140
* KafkaClient.least_loaded_node: pass bootstrap_fallback=True if needed (#2830)
43-
44-
Consumer
141+
* Consumer: add explicit bootstrap() method (#2975)
142+
* Admin: explicit bootstrap on __init__ (#2864)
143+
* Manage metadata refresh logic in ClusterMetadata via attached manager (#2920)
144+
* kafka.cluster: End refresh loop on close(); refresh loop catches KafkaError (#2935, #2936)
145+
* Respect metadata backoff in KafkaNetClient (#2854)
146+
147+
## Consumer
148+
149+
KafkaConsumer drops the dedicated HeartbeatThread in favor of scheduled async tasks on the kafka.net IO thread. Internals have been substantially refactored to migrate from future callbacks to async/await syntax. Feature support added for incremental cooperative rebalancing (KIP-429), rack-aware fetch (KIP-392), and log truncation detection (KIP-320/KIP-595).
150+
151+
### Threading and IO
152+
All consumer network I/O now flows through the shared kafka.net IO thread; `consumer.poll()` no longer drives the event loop directly.
153+
* Consumer: use background thread for all network io; drop HeartbeatThread (#2965)
154+
* Consumer: send all requests from net io thread (#2980)
155+
* Consumer: simplify poll() with fetcher.fetch_records (#2960)
156+
* Consumer: drop poll loop optimizations for pending offset resets and rejoins (#2959)
157+
* Consumer: `_update_fetch_positions` -> `_refresh_committed_offsets`; dont poll in position() (#2958)
158+
* Consumer: convert fetcher reset_offsets/send_list_offsets_requests to async def
159+
* Consumer: use new proto attrs in Fetcher (ListOffsets/Fetch) (#2923)
160+
161+
### Group Membership and Rebalance
162+
* KIP-429: Incremental Cooperative Rebalance (#2999)
163+
* KIP-429: Add on_partitions_lost rebalance listener hook (#3016)
164+
* KIP-559: Bump JoinGroup v7 / SyncGroup v5; verify protocol_type/name (#2998)
165+
* Rebalance Listener: raise errors, block fetches on revoked, pre-revoke unsubscribed (#3018)
166+
* Consumer: call RebalanceListener on close (#3020)
167+
* Preserve member id on IllegalGeneration error (#3017)
168+
169+
### Fetch
170+
* KIP-320: Detect and handle Log Truncation (#2978)
171+
* KIP-392: Rack-aware fetch from closest replica (#2986, #2996)
172+
* KIP-595: Fetch v12 support; check for log truncation and leader updates in response (#3021)
173+
* KAFKA-7548: Retain fetched data for paused partitions (#2981)
174+
* KAFKA-9212: Leader Epoch unreliable before Metadata v9 (#2997)
175+
176+
### Offsets and Commits
177+
* KIP-447: OffsetFetch v7 set require_stable flag if read_committed (#3023)
178+
* Consumer: handle retriable errors in offsets_for_times (#3022)
179+
* Consumer: Improve retriable offset fetch error handling (#2977)
180+
* Consumer: Retain subscription TopicPartitionState when possible (#3001)
181+
* Consumer: drop max_version clamp on ListOffsetsRequest (#3012)
182+
183+
### Configuration
184+
* KIP-602: Support client_dns_lookup in Consumer/Producer/Admin config (#3004)
185+
* Consumer: default request_timeout_ms 30s; use request-specific timeout for JoinGroup (#3011)
186+
187+
### Consumer Fixes
188+
* Retry metadata request if tracked topics have retriable errors (#2832)
45189
* Fix KeyError in KafkaConsumer.committed() (#2710)
46190
* Fix `Fetcher._fetch_offsets_by_times` retry handling (#2833)
47-
* Retry metadata request if tracked topics have retriable errors (#2832)
48191

49-
Producer
192+
## Producer
193+
194+
KafkaProducer gains a sticky partitioner (KIP-480), enabled-by-default idempotence (KIP-679), tightened transaction handling, and a faster send/encode path.
195+
196+
### Transactions and Idempotence
197+
* KIP-360 (pt1): Add transaction manager state and helper methods (#2852)
198+
* KIP-360 (pt2): Bump producer epoch with InitProducerIdRequest v3 on 2.5+ brokers (#2853)
199+
* KIP-447: Include group metadata in TxnOffsetCommitRequest (#2984, #2988)
200+
* KIP-654: Txn Producer aborts with non-fatal TransactionAbortedError (#3010)
201+
* KAFKA-5793: Tighten up semantics of OutOfOrderSequenceNumber (pt1) (#2843)
202+
* Enable producer idempotence with max_in_flight_requests_per_connection > 1 (#2841)
203+
* Producer: Enforce guaranteed message order when idempotence_enabled (#2937)
204+
* Producer: treat InvalidProducerEpochError as ProducerFencedError (#2885)
205+
* Producer: Improve transaction manager retriable error handling (#2884)
206+
* Producer: Use new-style request construction in Txn Manager (#2983)
207+
208+
### Partitioning
209+
* KIP-480: StickyPartitioner for KafkaProducer (#2982, #2989)
210+
211+
### Batching and Send Path
212+
Split-and-resend oversized batches instead of failing; avoid redundant validation and buffer copies on hot send-path.
213+
* KIP-126: Allow KafkaProducer to split and resend oversized batches (#2839)
214+
* Refactor producer.send / _wait_on_metadata for fast path (#2850)
215+
* Only ensure_valid_topic_name new topics on send (#2849)
216+
* Avoid unnecessary bytes/bytearray copies on send (#2845)
217+
* MemoryRecordsBuilder.build() returns bytearray buffer not bytes copy (#2842)
218+
* Drop PartitionResponse namedtuple; consolidate response and error handling (#2851)
219+
220+
### Producer Fixes
50221
* Fixup Sender error class logging (#2828)
51222

52-
Fixes
223+
## Admin Client
224+
225+
Split KafkaAdminClient into focused mixin classes (cluster, topics, configs, groups, ACLs, log dirs, etc), and convert request-sending path to async def methods that run on the kafka.net IO thread. Support for new KIPs using new protocol stack.
226+
227+
### Refactor and Async Migration
228+
The admin client interface remains sync but wraps a fully-async internal api (does not support asyncio yet). Adds cached coordinator lookups and a mixin structure to separate logical resource groups.
229+
* Admin: split into functional mixin classes (#2873, #2877, #2882)
230+
* Admin: convert request paths to async; cache coordinator_ids (#2851, #2862, #2863, #2866, #2867, #2870, #2871)
231+
* Admin: refactor `_send_request_to_controller` error handling (#2751)
232+
233+
### KIP Support
234+
* KIP-699: FindCoordinatorRequest v4 -- multi-group support (#3025)
235+
* KIP-709: OffsetFetch v8 -- use batch interface when available (#3024)
236+
237+
### New Cluster and Quorum APIs
238+
* Admin: describe_metadata_quorum (#2914)
239+
* Admin: cluster features describe/update (#2908)
240+
* Admin: cluster get_broker_version_data / api_versions (#2903)
241+
242+
### Configs
243+
* Admin: list_config_resources (requires 4.1+) (#2900)
244+
* Admin: support incremental alter configs (#2901)
245+
* Admin: Improve alter_configs w/ filters and missing keys (#2899)
246+
247+
### Topics and Partitions
248+
* KIP-516: Support topic id (uuid) for describe topics (#3031)
249+
* Admin: re-use config processing for CreateTopicsResponse (#3036)
250+
* Admin: wait_for_topics() and create_topics() wait_for_metadata option (#2856)
251+
* Admin: list_partition_offsets (#2894)
252+
* Admin: Expand partitions api support (#2890)
253+
* Admin: Cleanup alter_partition_reassignments (#3002)
254+
255+
256+
### Groups
257+
* Admin: include latest offsets and lag in list_group_offsets; add reset_group_offsets (#2897)
258+
* Admin: support group state/type filters for list_groups (#2910)
259+
* Admin: add extended group reset options (#2911)
260+
* Admin: Dont return MemberToRemove as key in remove_group_members dict result (#2893)
261+
262+
### Log Dirs
263+
* Admin: alter_log_dirs (#2912)
264+
* Admin: Fix describe_log_dirs, accept optional topics/brokers (#2881)
265+
266+
### Reliability
267+
* Admin: retry delete_records / list_partition_offsets on NotLeaderForPartitionError (#2976)
268+
269+
## CLI
270+
271+
The CLI adds shared parser config, SASL/SSL connection support across all subcommands, and several new admin subcommands (acls, configs alter, users).
272+
273+
### Common Infrastructure
274+
* Add kafka-python cli script to wrap admin/consumer/producer (#3034)
275+
* kafka.cli: common parser args; support sasl/ssl connections (#2887)
276+
* kafka.cli: common configuration for logging and connect kwargs (#2906)
277+
* Add --enable-logger/--disable-logger to cli options (#2798)
278+
* Set default cli log level => CRITICAL (#2760)
279+
280+
### Admin CLI
281+
* admin cli: acls, users, configs alter (#2888)
282+
* admin cli: refactor admin group/command parsers; consumer/producer option groups (#2909)
283+
* admin cli: --id support for describe-topics
284+
* admin cli: close() after running command
285+
* admin cli: dont print stacktrace for BrokerResponseError or ValueError (#2895)
286+
* admin cli: catch AttributeError and print_help() (#2880)
287+
* admin cli: fix describe_configs (#2875)
288+
289+
## Compatibility / Misc
290+
291+
Small quality-of-life additions to the public API surface.
292+
293+
* Support context manager interface for consumer/producer/admin (#2969)
294+
* Make IncompatibleBrokerVersion a subclass of UnsupportedVersionError (#2924)
295+
* Add OffsetSpec / IsolationLevel to kafka imports (#2898)
296+
297+
## Fixes
298+
299+
Codec and Python-3-compatibility fixes that aren't specific to a single client.
300+
53301
* Fix zstd multi-frame decompression failure (#2717)
54302
* Use time.monotonic() instead of time.time() for elapsed time calculations (#2714)
303+
* Fix deprecated log.warn() -> log.warning()
304+
* REF: Switch to deque.copy() for Python 3 compatibility (#2712)
305+
306+
## Tests
307+
308+
A new in-memory `MockBroker` / `MockTransport` enables deterministic protocol-level tests, and the integration test fixtures have been substantially consolidated.
309+
310+
### MockBroker and Fixtures
311+
* MockBroker / MockTransport for deterministic protocol tests (#2861, #2902)
312+
* Organize test files into consumer/ producer/ admin/ directories (#2844)
313+
* Consolidate consumer integration tests (#2857)
314+
* Consolidate more pytest fixtures (admin/client) (#2921)
315+
* Integration fixtures use contextmanager (#2966)
316+
* Refactor coordinator test fixtures; prefer MockBroker to patched_coord (#2953)
317+
* Support SSL transports in KafkaFixture (#2806)
318+
* Simplify interacting with KafkaFixture (client factories, create_topics) (#2808)
319+
* Use producer/consumer/admin factories in producer_integration tests (#2829)
320+
* Set api_version for integration tests; fix test_group missing consumers (#2824)
321+
* Close local fixtures in tests (#2962)
322+
* Catch exceptions in fixture.open() -> close() (#2907)
323+
* Create topic on 0.8.2 broker to fix bootstrap (#2896)
324+
325+
### Reliability
326+
* Reduce timing flakiness in test_group (#3006)
327+
* Test timeouts: use pytest-timeout method=thread and add faulthandler
328+
329+
## Project Infra
55330

56-
Project Infra
57331
* Enable pylint workflow; disable/fix all outstanding errors (#2701)
58332
* Add coverage step to CI (#2786)
59-
* CI test matrix updated to Kafka 4.0-4.2
60-
* Bump actions/cache from 4 to 5 (#2702)
61-
* Bump actions/upload-artifact from 4 to 7 (#2789)
333+
* CI test matrix updated to python 3.14 / kafka 4.3 (#2836, #3032)
334+
* Add lint-unicode make target; include in make lint test (#2993)
335+
* pyproject updates: no more universal wheels; requres py3.8+; fix license files; drop setup.py (#3033)
336+
* Bump actions/cache from 4 to 5; actions/upload-artifact from 4 to 7 (#2702, #2789)
62337

63338
# 2.3.1 (Apr 9, 2026)
64339

0 commit comments

Comments
 (0)