Browse Source
CRITICAL BUG FIX: The recordSetData slice was sharing the underlying array with the request buffer, causing data corruption when the request buffer was reused or modified. This led to Kafka record batch header bytes overwriting stored message data, resulting in corrupted messages like: Expected: 'test-message-kafka-go-default' Got: '������������kafka-go-default' The corruption pattern matched Kafka batch header bytes (0x01, 0x00, 0xFF, etc.) indicating buffer sharing between the produce request parsing and message storage. SOLUTION: Make a defensive copy of recordSetData in both produce request handlers (handleProduceV0V1 and handleProduceV2Plus) to prevent slice aliasing issues. Changes: - weed/mq/kafka/protocol/produce.go: Copy recordSetData to prevent buffer sharing - Remove debug logging added during investigation Fixes: - TestClientCompatibility/KafkaGoVersionCompatibility/kafka-go-default - TestClientCompatibility/KafkaGoVersionCompatibility/kafka-go-with-batching - Message content mismatch errors in GitHub Actions CI This was a subtle memory safety issue that only manifested under certain timing conditions, making it appear intermittent in CI environments. Make a copy of recordSetData to prevent buffer sharing corruptionpull/7329/head
4 changed files with 1 additions and 65 deletions
Loading…
Reference in new issue