mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-19 21:10:48 +02:00
PARTIAL FIX: Force kafka-go to use Metadata v4 instead of v6 ## Issue Identified: - kafka-go was using Metadata v6 due to ApiVersions advertising v0-v6 - Our Metadata v6 implementation has format issues causing client failures - Sarama works because it uses Metadata v4, not v6 ## Changes: - Limited Metadata API max version from 6 to 4 in ApiVersions response - Added debug test to isolate Metadata parsing issues - kafka-go now uses Metadata v4 (same as working Sarama) ## Status: - ✅ kafka-go now uses v4 instead of v6 - ❌ Still has metadata loops (deeper issue with response format) - ✅ Produce operations work correctly - ❌ ReadPartitions API still fails ## Next Steps: - Investigate why kafka-go keeps requesting metadata even with v4 - Compare exact byte format between working Sarama and failing kafka-go - May need to fix specific fields in Metadata v4 response format This is progress toward full kafka-go compatibility but more investigation needed.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package kafka
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/segmentio/kafka-go"
|
|
"github.com/seaweedfs/seaweedfs/weed/mq/kafka/gateway"
|
|
)
|
|
|
|
func TestMetadataV6Debug(t *testing.T) {
|
|
// Start gateway
|
|
gatewayServer := gateway.NewServer(gateway.Options{Listen: "127.0.0.1:0"})
|
|
go func() {
|
|
if err := gatewayServer.Start(); err != nil {
|
|
t.Errorf("Failed to start gateway: %v", err)
|
|
}
|
|
}()
|
|
defer gatewayServer.Close()
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
host, port := gatewayServer.GetListenerAddr()
|
|
addr := fmt.Sprintf("%s:%d", host, port)
|
|
topic := "metadata-debug-topic"
|
|
gatewayServer.GetHandler().AddTopicForTesting(topic, 1)
|
|
|
|
// Create a simple kafka-go client that just gets metadata
|
|
conn, err := kafka.Dial("tcp", addr)
|
|
if err != nil {
|
|
t.Fatalf("Failed to connect: %v", err)
|
|
}
|
|
defer conn.Close()
|
|
|
|
// Get metadata - this should work without loops
|
|
partitions, err := conn.ReadPartitions(topic)
|
|
if err != nil {
|
|
t.Fatalf("Failed to read partitions: %v", err)
|
|
}
|
|
|
|
t.Logf("Successfully read %d partitions for topic %s", len(partitions), topic)
|
|
for _, p := range partitions {
|
|
t.Logf("Partition %d: Leader=%d, Replicas=%v, ISR=%v",
|
|
p.ID, p.Leader.ID, p.Replicas, p.Isr)
|
|
}
|
|
} |