Repository navigation
Replies: 2 comments
TriageVerdict: A reproducible bug in the tests' Is this a misuse of humus?No. No end user's code is involved. queue/kafka's tests have the same helper, in Is it a feature request?No. The behaviour contradicts what the walkthrough and the Kafka page promise:
The fix is in test helpers and one docs sample. It changes no API. Is it reproducible?Yes. At 6351c86, with Go 1.27.0 (CI runs 1.27.2), franz-go v1.22.2, kmsg v1.15.0 and kfake
The forced tests use As kgo sends it: the first Fetch leaves out the events' partition. The CLI produces order-1's four events to partition 10. This is the failing run of the test that logs its requests:
Over its 1,200 runs, the first Fetch named all twelve partitions 1,182 times, 11 partitions 14 times, 10 three times and 9 once. Only the run whose first Fetch left out partition 10 failed. A partial first Fetch that still names the events' partition reads all four. A passing run looks like this: Forced: two orders, one of their partitions left out. In one run, the two random IDs land on partitions 5 and 9, and 5 is faulted:
Over 100 runs, it read one order's events in 93, and neither order's in 7. In each of those 7, both orders were on the faulted partition. CI's failing run of this test, 39519086159, read neither order, and so did the unchanged test's failing run here: Forced, in queue/kafka: the This corrects the report on one point. Why
With one partition, the first Fetch either names it or isn't sent. So the #1256 is filed to fix it:
|
|
Fixed by #1257 (#1257), merged as 08b44fa, for story #1256.
The triage's forced reproductions are now tests: |
Uh oh!
There was an error while loading. Please reload this page.
What happens
TestInit_produces_the_order_s_events_keyed_by_its_ID_in_orderinexample/orderstatus/cmd/ordereventsfails intermittently onmain, in the merge queue and on PRs, e.g. run 39678387044 onmain:The CLI exits 0 and prints the order ID, so the four events were produced. The test's
readAllthen reads none of them back.Since the test landed on 2026-10-19 (#1079) it has failed 17 times in about 310 CI runs, roughly 1 run in 18. Sixteen of the failures are this test. One is its sibling,
TestInit_without_an_order_ID_makes_a_random_one_and_prints_it, which uses the samereadAlland fails withelements differ:mainmainmainmainmainmainmainWhy
This hasn't been triaged. What follows comes from the code and a reproduction.
readAllpolls with a one-second timeout and stops at the first poll that returns no records. That poll can come back empty while the records are still unread.The cluster seeds
orders.eventswith 12 partitions, and the four events land on one of them. After kgo lists the start offsets, it makes each partition's cursor usable one at a time (consumer.go#L2284-L2290). The first cursor starts the fetch loop (source.go#L265-L271,source.go#L858-L866), so the first Fetch can go out with only the partitions that were usable by then. If the events' partition isn't one of them, kfake holds the Fetch for kgo's defaultFetchMaxWaitof 5s, and the other partitions wait for the next Fetch. The test runs in asynctestbubble, so the fake clock jumps toreadAll's one-second deadline first, and the empty poll ends the read.Reproduction. On
main(6351c86), with no code change, atGOMAXPROCS=4:This failed 2 of 300 runs. It didn't fail at
GOMAXPROCS=1or2. Running eight copies at once,TestInit_without_an_order_ID_makes_a_random_one_and_prints_itfailed 2 of 3,200 runs the same way.To see the partial Fetch, I gave
readAll's client a debug logger and recorded the size of its first Fetch request. Each partition adds 33 bytes, so 457 bytes is all 12 partitions. Over 3,200 runs:Every failure had a partial first Fetch. A partial Fetch that included the events' partition read all four events. In a failing run the log shows the Fetch written, nothing read for one second, then the poll canceled:
The same
readAllloop is also inexample/orderstatus/app/app_test.goandqueue/kafka/producer_test.go. Theapptests only read one-partition topics, and with one partition the first Fetch always includes it.TestProduce_keeps_the_order_of_records_with_one_keyreads a three-partition topic. It passed 2,000 of 2,000 runs locally and hasn't failed in CI.Expected
The
ordereventstests read back every event the CLI produced, whichever partitions kgo's first Fetch covers. They fail only when the CLI is broken.References
readAlland the 12-partition clusterTestInit_produces_the_order_s_events_keyed_by_its_ID_in_orderAll reactions