Browse Source
Phase 13: CRITICAL BUG FIX - Error Code Mismatch
Problem:
Producer CreateTopic calls were failing with confusing error:
'kafka server: The requested offset is outside the range of offsets...'
But the real error was topic creation failure!
Root Cause:
SeaweedFS had WRONG error code mappings:
ErrorCodeUnknownServerError = 1 ← WRONG!
ErrorCodeOffsetOutOfRange = 2 ← WRONG!
Official Kafka protocol:
-1 = UNKNOWN_SERVER_ERROR
1 = OFFSET_OUT_OF_RANGE
When CreateTopics handler returned errCode=1 for topic creation failure,
Sarama client interpreted it as OFFSET_OUT_OF_RANGE, causing massive confusion!
The Flow:
1. Producer tries to create loadtest-topic-2
2. CreateTopics handler fails (schema fetch error), returns errCode=1
3. Sarama interprets errCode=1 as OFFSET_OUT_OF_RANGE (not UNKNOWN_SERVER_ERROR!)
4. Producer logs: 'The requested offset is outside the range...'
5. Producer continues anyway (only warns on non-TOPIC_ALREADY_EXISTS errors)
6. Consumer tries to consume from non-existent topic-2
7. Gets 'topic does not exist' → rebalances → starts from offset 0 → DUPLICATES!
Fix:
1. Corrected error code constants:
ErrorCodeUnknownServerError = -1 (was 1)
ErrorCodeOffsetOutOfRange = 1 (was 2)
2. Updated all error handlers to use 0xFFFF (uint16 representation of -1)
3. Now topic creation failures return proper UNKNOWN_SERVER_ERROR
Expected Result:
- CreateTopic failures will be properly reported
- Producers will see correct error messages
- No more confusing OFFSET_OUT_OF_RANGE errors during topic creation
- Should eliminate topic persistence race causing duplicates
pull/7329/head
3 changed files with 9 additions and 9 deletions
Loading…
Reference in new issue