Skip to content

Commit f878765

Browse files
fangnxemasabMSealk-rainastevebang
authored
Merge async branch to master (#2080)
* Asyncio Producer and Consumer implementation with same API as the sync ones * Add unit tests for asyncio producer + consumer (#2036) * update * update * fix producer and add consumer uts * refactor * rename * Add Benchmark Framework for ducktape (#2030) * Integrate Schema Registry with ducktape load tests (#2027) * basic sr test * more tests * update * update * lint * Add ducktape benchmark tests for consumer (sync + async) (#2045) * draft * update and cleanup * add perf comments, add batch_size param to consume test, lint fix * linter fix * Fix linter issues in consumer testing code (#2051) * Add remaining functions missing in async producer & consumer (#2050) * Add semaphore block for ducktape tests (#2037) * Add semaphore block for ducktape tests * Increase kafka start timeout * Increase kafka start timeout * Increase kafka start timeout * Add logs to debug pipeline * Start kafka in kraft mode * Fix directory failures * Fix directory failures * Fix directory failures * templatise path * Fix ductape run * Fix kafka broker listner * Fix ducktape version error * Cleanup * Fix bound voilation should fail tests * Now expand bounds for success * Add schema registry instance * Update Schema Registry hostname * Update Schema Registry hostname * Update Schema Registry hostname * Fix for linux CI environment * Address minor feedback * Fix semaphore * Minor fix after rebase * Add more async consumer unit & integration tests (#2052) * basic rebalance test * rebalance tests * refactor and linter fix * feebdack * refactor and cleanup * update * remove jit imports * Add produce batch api to producer (#2047) * Add integration tests for transactions (#2056) * add tests * cleanup and linter fix * remove jit import * refactor * cleanup * minot rlinter * Update AsyncIO producer architecture to improve performance (#2044) * Fix helper function name to avoid ducktape test discovery * Integrate schema registry with producer sync/async performance test + clean up the old SR test (#2063) * Add comprehensive producer benchmark tests with Schema Registry support - Updated message serialization to use comprehensive structure with all protobuf fields - Implemented proper strategy pattern for sync/async serializers - Added Schema Registry authentication configuration - Fixed JSON serialization issues (schema title, async serializer initialization) - Added performance validation with configurable JSON validation - Enhanced producer strategies with comprehensive Avro, JSON, and Protobuf support * remove * remove confusing msg * Minor: Producer close calls flush() (#2066) * Integrate schema registry with consumer sync/async performance test (#2059) * update * remove auth * cleanup and ensure same msg size * more cleanup * Add comprehensive producer benchmark tests with Schema Registry support - Updated message serialization to use comprehensive structure with all protobuf fields - Implemented proper strategy pattern for sync/async serializers - Added Schema Registry authentication configuration - Fixed JSON serialization issues (schema title, async serializer initialization) - Added performance validation with configurable JSON validation - Enhanced producer strategies with comprehensive Avro, JSON, and Protobuf support * update * Group messages by topic partition before passing to produce_batch API (#2069) * Merge master to async (#2068) * Pre release (#2067) * Attempting to add python versioning to read from project toml and setting beta flag * Updated docs to read project toml version as well * Updated to read from c file for now. Updaed docs and fixed bad AI code * NPI-7572: Add content for AsyncIO Python client (#2070) * Updates for AsyncIO and other improvements * Add updates based on asyncio blog * Add SR updates relatd to AsyncIO * Reorganize content, remove redundancy, and improve content * Edits to diagram and other content * Add why to use this client in both readme files * Improve CHANGELOG title * Add release dates to versions in CHANGELOG * Add release dates back to v2.4.0 * Edits based on feedback * AsyncIO: Only clear messages from buffer if executor passed (#2071) * Fix async producer transaction behavior + add transactional produce benchmark test (#2072) * update * linter fix * Fix the async transaction behavior related to flush() (#2073) * fix * linter * more linter fix * linter and add link * Removed very old librdkafka version checks * Resolved admin import conflict issue * Fix test_version unit test (#2079) * Fix broken tests (#2077) * fix tests * fix linter * Removed set operation from test --------- Co-authored-by: Matthew Seal <[email protected]> * Async fix buffer cleanup (#2078) * Fix buffer cleanup logic * Add tests * fix linter * Remove SR key * Removed incorrect assert * Change ducktape tests to install more dependencies * Fix semaphore for producer ducktape tests + clean up files that should've been removed (#2081) * update * use warning for producer validate * remove unnecessary assert --------- Co-authored-by: Emanuele Sabellico <[email protected]> Co-authored-by: Matthew Seal <[email protected]> Co-authored-by: Kaushik Raina <[email protected]> Co-authored-by: Matthew Seal <[email protected]> Co-authored-by: Steve Bang <[email protected]>
1 parent b67c0aa commit f878765

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+8166
-1027
lines changed

.ducktape/metadata/session_id

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ venv_examples
3434
.coverage
3535
**/coverage.xml
3636
**/test-report.xml
37-
*.ducktape
37+
.ducktape
38+
results

.semaphore/semaphore.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,106 @@ blocks:
275275
- python3 -m venv _venv && source _venv/bin/activate
276276
- chmod u+r+x tools/source-package-verification.sh
277277
- tools/source-package-verification.sh
278+
- name: "Ducktape Performance Tests (Linux x64)"
279+
dependencies: []
280+
task:
281+
agent:
282+
machine:
283+
type: s1-prod-ubuntu24-04-amd64-3
284+
env_vars:
285+
- name: OS_NAME
286+
value: linux
287+
- name: ARCH
288+
value: x64
289+
- name: BENCHMARK_BOUNDS_CONFIG
290+
value: tests/ducktape/producer_benchmark_bounds.json
291+
- name: BENCHMARK_ENVIRONMENT
292+
value: ci
293+
prologue:
294+
commands:
295+
- '[[ -z $DOCKERHUB_APIKEY ]] || docker login --username $DOCKERHUB_USER --password $DOCKERHUB_APIKEY'
296+
jobs:
297+
- name: Build and Tests
298+
commands:
299+
# Setup Python environment
300+
- sem-version python 3.9
301+
- python3 -m venv _venv && source _venv/bin/activate
302+
303+
# Install ducktape framework and additional dependencies
304+
- pip install ducktape psutil
305+
306+
# Install existing test requirements
307+
- pip install -r requirements/requirements-tests-install.txt
308+
309+
# Build and install confluent-kafka from source
310+
- lib_dir=dest/runtimes/$OS_NAME-$ARCH/native
311+
- tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
312+
- export CFLAGS="$CFLAGS -I${PWD}/dest/build/native/include"
313+
- export LDFLAGS="$LDFLAGS -L${PWD}/${lib_dir}"
314+
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/$lib_dir"
315+
- python3 -m pip install -e .
316+
317+
# Store project root for reliable navigation
318+
- PROJECT_ROOT="${PWD}"
319+
320+
# Start Kafka cluster and Schema Registry using dedicated ducktape compose file (KRaft mode)
321+
- cd "${PROJECT_ROOT}/tests/docker"
322+
- docker-compose -f docker-compose.ducktape.yml up -d kafka schema-registry
323+
324+
# Debug: Check container status and logs
325+
- echo "=== Container Status ==="
326+
- docker-compose -f docker-compose.ducktape.yml ps
327+
- echo "=== Kafka Logs ==="
328+
- docker-compose -f docker-compose.ducktape.yml logs kafka | tail -50
329+
330+
# Wait for Kafka to be ready (using PLAINTEXT listener for external access)
331+
- |
332+
timeout 1800 bash -c '
333+
counter=0
334+
until docker-compose -f docker-compose.ducktape.yml exec -T kafka kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1; do
335+
echo "Waiting for Kafka... (attempt $((counter+1)))"
336+
337+
# Show logs every 4th attempt (every 20 seconds)
338+
if [ $((counter % 4)) -eq 0 ] && [ $counter -gt 0 ]; then
339+
echo "=== Recent Kafka Logs ==="
340+
docker-compose -f docker-compose.ducktape.yml logs --tail=10 kafka
341+
echo "=== Container Status ==="
342+
docker-compose -f docker-compose.ducktape.yml ps kafka
343+
fi
344+
345+
counter=$((counter+1))
346+
sleep 5
347+
done
348+
'
349+
- echo "Kafka cluster is ready!"
350+
351+
# Wait for Schema Registry to be ready
352+
- echo "=== Waiting for Schema Registry ==="
353+
- |
354+
timeout 300 bash -c '
355+
counter=0
356+
until curl -f http://localhost:8081/subjects >/dev/null 2>&1; do
357+
echo "Waiting for Schema Registry... (attempt $((counter+1)))"
358+
359+
# Show logs every 3rd attempt (every 15 seconds)
360+
if [ $((counter % 3)) -eq 0 ] && [ $counter -gt 0 ]; then
361+
echo "=== Recent Schema Registry Logs ==="
362+
docker-compose -f docker-compose.ducktape.yml logs --tail=10 schema-registry
363+
echo "=== Schema Registry Container Status ==="
364+
docker-compose -f docker-compose.ducktape.yml ps schema-registry
365+
fi
366+
367+
counter=$((counter+1))
368+
sleep 5
369+
done
370+
'
371+
- echo "Schema Registry is ready!"
372+
373+
# Run standard ducktape tests with CI bounds
374+
- cd "${PROJECT_ROOT}" && PYTHONPATH="${PROJECT_ROOT}" python tests/ducktape/run_ducktape_test.py
375+
376+
# Cleanup
377+
- cd "${PROJECT_ROOT}/tests/docker" && docker-compose -f docker-compose.ducktape.yml down -v || true
278378
- name: "Packaging"
279379
run:
280380
when: "tag =~ '.*'"

CHANGELOG.md

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1-
# Confluent's Python client for Apache Kafka
1+
# Confluent Python Client for Apache Kafka - CHANGELOG
22

3-
## v2.11.1
3+
## Unreleased
4+
5+
### Added
6+
7+
- AsyncIO Producer (experimental): Introduces `confluent_kafka.aio.AIOProducer` for
8+
asynchronous message production in asyncio applications. This API offloads
9+
blocking librdkafka calls to a thread pool and schedules common callbacks
10+
(`error_cb`, `throttle_cb`, `stats_cb`, `oauth_cb`, `logger`) onto the event
11+
loop for safe usage inside async frameworks.
12+
13+
### Features
14+
15+
- Batched async produce: `await aio.AIOProducer(...).produce(topic, value=...)`
16+
buffers messages and flushes when the buffer threshold or timeout is reached.
17+
- Async lifecycle: `await producer.flush()`, `await producer.purge()`, and
18+
transactional operations (`init_transactions`, `begin_transaction`,
19+
`commit_transaction`, `abort_transaction`).
20+
21+
### Limitations
22+
23+
- Per-message headers are not supported in the current batched async produce
24+
path. If headers are required, use the synchronous `Producer.produce(...)` or
25+
offload a sync produce call to a thread executor within your async app.
26+
27+
### Guidance
28+
29+
- Use the AsyncIO Producer inside async apps/servers (FastAPI/Starlette, aiohttp,
30+
asyncio tasks) to avoid blocking the event loop.
31+
- For batch jobs, scripts, or highest-throughput pipelines without an event
32+
loop, the synchronous `Producer` remains recommended.
33+
34+
## v2.11.1 - 2025-08-18
435

536
v2.11.1 is a maintenance release with the following fixes:
637

@@ -9,7 +40,7 @@ confluent-kafka-python v2.11.1 is based on librdkafka v2.11.1, see the
940
for a complete list of changes, enhancements, fixes and upgrade considerations.
1041

1142

12-
## v2.11.0
43+
## v2.11.0 - 2025-07-03
1344

1445
v2.11.0 is a feature release with the following enhancements:
1546

@@ -18,7 +49,7 @@ confluent-kafka-python v2.11.0 is based on librdkafka v2.11.0, see the
1849
for a complete list of changes, enhancements, fixes and upgrade considerations.
1950

2051

21-
## v2.10.1
52+
## v2.10.1 - 2025-06-11
2253

2354
v2.10.1 is a maintenance release with the following fixes:
2455

@@ -34,7 +65,7 @@ confluent-kafka-python v2.10.1 is based on librdkafka v2.10.1, see the
3465
[librdkafka release notes](https://github.com/confluentinc/librdkafka/releases/tag/v2.10.1)
3566
for a complete list of changes, enhancements, fixes and upgrade considerations.
3667

37-
## v2.10.0
68+
## v2.10.0 - 2025-04-18
3869

3970
v2.10.0 is a feature release with the following fixes and enhancements:
4071

@@ -45,7 +76,7 @@ confluent-kafka-python v2.10.0 is based on librdkafka v2.10.0, see the
4576
[librdkafka release notes](https://github.com/confluentinc/librdkafka/releases/tag/v2.10.0)
4677
for a complete list of changes, enhancements, fixes and upgrade considerations.
4778

48-
## v2.9.0
79+
## v2.9.0 - 2025-03-28
4980

5081
v2.9.0 is a feature release with the following fixes and enhancements:
5182

@@ -58,7 +89,7 @@ confluent-kafka-python v2.9.0 is based on librdkafka v2.8.0, see the
5889
[librdkafka release notes](https://github.com/confluentinc/librdkafka/releases/tag/v2.8.0)
5990
for a complete list of changes, enhancements, fixes and upgrade considerations.
6091

61-
## v2.8.2
92+
## v2.8.2 - 2025-02-28
6293

6394
v2.8.2 is a maintenance release with the following fixes and enhancements:
6495

@@ -73,7 +104,7 @@ Note: Versioning is skipped due to breaking change in v2.8.1.
73104
Do not run software with v2.8.1 installed.
74105

75106

76-
## v2.8.0
107+
## v2.8.0 - 2025-01-07
77108

78109
v2.8.0 is a feature release with the features, fixes and enhancements:
79110

@@ -82,7 +113,7 @@ confluent-kafka-python v2.8.0 is based on librdkafka v2.8.0, see the
82113
for a complete list of changes, enhancements, fixes and upgrade considerations.
83114

84115

85-
## v2.7.0
116+
## v2.7.0 - 2024-12-21
86117

87118
v2.7.0 is a feature release with the features, fixes and enhancements present in v2.6.2 including the following fix:
88119

@@ -93,7 +124,7 @@ confluent-kafka-python v2.7.0 is based on librdkafka v2.6.1, see the
93124
for a complete list of changes, enhancements, fixes and upgrade considerations.
94125

95126

96-
## v2.6.2
127+
## v2.6.2 - 2024-12-18
97128

98129
> [!WARNING]
99130
> Due to an error in which we included dependency changes to a recent patch release, Confluent recommends users to **refrain from upgrading to 2.6.2** of Confluent Kafka. Confluent will release a new minor version, 2.7.0, where the dependency changes will be appropriately included. Users who have already upgraded to 2.6.2 and made the required dependency changes are free to remain on that version and are recommended to upgrade to 2.7.0 when that version is available. Upon the release of 2.7.0, the 2.6.2 version will be marked deprecated.
@@ -136,7 +167,7 @@ confluent-kafka-python is based on librdkafka v2.6.1, see the
136167
for a complete list of changes, enhancements, fixes and upgrade considerations.
137168

138169

139-
## v2.6.1
170+
## v2.6.1 - 2024-11-18
140171

141172
v2.6.1 is a maintenance release with the following fixes and enhancements:
142173

@@ -149,7 +180,7 @@ confluent-kafka-python is based on librdkafka v2.6.1, see the
149180
for a complete list of changes, enhancements, fixes and upgrade considerations.
150181

151182

152-
## v2.6.0
183+
## v2.6.0 - 2024-10-11
153184

154185
v2.6.0 is a feature release with the following features, fixes and enhancements:
155186

@@ -163,7 +194,7 @@ confluent-kafka-python is based on librdkafka v2.6.0, see the
163194
for a complete list of changes, enhancements, fixes and upgrade considerations.
164195

165196

166-
## v2.5.3
197+
## v2.5.3 - 2024-09-02
167198

168199
v2.5.3 is a maintenance release with the following fixes and enhancements:
169200

@@ -178,7 +209,7 @@ for a complete list of changes, enhancements, fixes and upgrade considerations.
178209

179210

180211

181-
## v2.5.0
212+
## v2.5.0 - 2024-07-10
182213

183214
> [!WARNING]
184215
This version has introduced a regression in which an assert is triggered during **PushTelemetry** call. This happens when no metric is matched on the client side among those requested by broker subscription.
@@ -211,7 +242,7 @@ confluent-kafka-python is based on librdkafka v2.5.0, see the
211242
for a complete list of changes, enhancements, fixes and upgrade considerations.
212243

213244

214-
## v2.4.0
245+
## v2.4.0 - 2024-05-07
215246

216247
v2.4.0 is a feature release with the following features, fixes and enhancements:
217248

0 commit comments

Comments
 (0)