You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.6 KiB
3.6 KiB
Kafka API Version Matrix Audit
Summary
This document audits the advertised API versions in handleApiVersions() against actual implementation support and identifies mismatches that need correction.
Current Status: MISMATCHES FOUND ⚠️
API Version Discrepancies
| API Key | API Name | Advertised | Actually Implemented | Status | Action Needed |
|---|---|---|---|---|---|
| 18 | ApiVersions | v0-v3 | v0-v3 | ✅ Match | None |
| 3 | Metadata | v0-v7 | v0-v7 | ✅ Match | None |
| 0 | Produce | v0-v7 | v0-v7 | ✅ Match | None |
| 1 | Fetch | v0-v7 | v0-v7 | ✅ Match | None |
| 2 | ListOffsets | v0-v2 | v0-v2 | ✅ Match | None |
| 19 | CreateTopics | v0-v4 | v0-v5 | ❌ Mismatch | Update advertised to v0-v5 |
| 20 | DeleteTopics | v0-v4 | v0-v4 | ✅ Match | None |
| 11 | JoinGroup | v0-v7 | v0-v7 | ✅ Match | None |
| 14 | SyncGroup | v0-v5 | v0-v5 | ✅ Match | None |
| 8 | OffsetCommit | v0-v2 | v0-v2 | ✅ Match | None |
| 9 | OffsetFetch | v0-v2 | v0-v5+ | ❌ MAJOR Mismatch | Update advertised to v0-v5 |
| 10 | FindCoordinator | v0-v2 | v0-v2 | ✅ Match | None |
| 12 | Heartbeat | v0-v4 | v0-v4 | ✅ Match | None |
| 13 | LeaveGroup | v0-v4 | v0-v4 | ✅ Match | None |
Detailed Analysis
1. OffsetFetch API (Key 9) - CRITICAL MISMATCH
- Advertised: v0-v2 (max version 2)
- Actually Implemented: Up to v5+
- Evidence:
buildOffsetFetchResponse()includesif apiVersion >= 5for leader epoch - Evidence:
if apiVersion >= 3for throttle time
- Evidence:
- Impact: Clients may not use advanced features available in v3-v5
- Action: Update advertised max version from 2 to 5
2. CreateTopics API (Key 19) - MINOR MISMATCH
- Advertised: v0-v4 (max version 4)
- Actually Implemented: v0-v5
- Evidence:
handleCreateTopics()routes v5 requests tohandleCreateTopicsV2Plus() - Evidence: Tests validate v0-v5 versions
- Evidence:
- Impact: v5 clients may not connect expecting v5 support
- Action: Update advertised max version from 4 to 5
3. Validation vs Advertisement Inconsistency
The validateAPIVersion() function matches the advertised versions, which means it will incorrectly reject valid v3-v5 OffsetFetch requests that the handler can actually process.
Implementation Details
OffsetFetch Version Features:
- v0-v2: Basic offset fetch
- v3+: Includes throttle_time_ms
- v5+: Includes leader_epoch for each partition
CreateTopics Version Features:
- v0-v1: Regular array format
- v2-v5: Compact array format, tagged fields
Recommendations
- Immediate Fix: Update
handleApiVersions()to advertise correct max versions - Consistency Check: Update
validateAPIVersion()to match the corrected advertised versions - Testing: Verify that higher version clients can successfully connect and use advanced features
- Documentation: Update any client guidance to reflect the correct supported versions
Test Verification Needed
After fixes:
- Test OffsetFetch v3, v4, v5 with real Kafka clients
- Test CreateTopics v5 with real Kafka clients
- Verify throttle_time_ms and leader_epoch are correctly populated
- Ensure version validation doesn't reject valid higher version requests
Conservative Alternative
If we want to be conservative and not advertise versions we haven't thoroughly tested:
- OffsetFetch: Limit to v3 (throttle time support) instead of v5
- CreateTopics: Keep at v4 unless v5 is specifically needed
This would still fix the main discrepancy while being more cautious about untested version features.