You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Wait for compaction to occur (may take time on slower systems)
2035
+
time.Sleep(2*time.Second)
2036
+
2037
+
for {
2038
+
success:=func() bool {
2039
+
r:=NewReader(ReaderConfig{
2040
+
Brokers: []string{"localhost:9092"},
2041
+
Topic: topic,
2042
+
MinBytes: 200,
2043
+
MaxBytes: 200,
2044
+
MaxWait: 100*time.Millisecond,
2045
+
})
2046
+
deferr.Close()
2047
+
2048
+
keys:=map[string]int{}
2049
+
2050
+
// This loop should NOT hang indefinitely
2051
+
// If it does, we have the CPU spinning bug
2052
+
for {
2053
+
m, err:=r.FetchMessage(ctx)
2054
+
iferr!=nil {
2055
+
iferrors.Is(err, context.DeadlineExceeded) {
2056
+
t.Fatalf("Reader CPU spinning detected - stuck in (*reader).read after processing compressed compacted batches. This indicates the lengthRemain bug in message_reader.go")
2057
+
}
2058
+
t.Logf("can't get message from compacted log: %v", err)
2059
+
returnfalse
2060
+
}
2061
+
keys[string(m.Key)]++
2062
+
2063
+
iflen(keys) ==countKeys(msgs) {
2064
+
t.Logf("got keys: %+v", keys)
2065
+
returnreflect.DeepEqual(keys, expectedKeys)
2066
+
}
2067
+
}
2068
+
}()
2069
+
ifsuccess {
2070
+
return
2071
+
}
2072
+
select {
2073
+
case<-ctx.Done():
2074
+
t.Fatal("Test timed out - likely due to CPU spinning bug in compressed compacted topic processing")
2075
+
default:
2076
+
}
2077
+
}
2078
+
}
2079
+
2080
+
// writeCompressedMessagesForCompaction writes compressed messages with specific
2081
+
// writer configuration that combines compression with compaction-friendly patterns.
2082
+
// This helper creates the exact conditions needed to reproduce the lengthRemain bug.
0 commit comments