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
{{ message }}
Repository navigation
TestJobArrayIDSuffixIsNotTheClock flakes: 2000 draws from a 32-bit suffix collide about 1 run in 2000 #1044
TestJobArrayIDSuffixIsNotTheClock (cmd/launch_jobarray_token_test.go, #710) fails intermittently. It calls generateJobArrayID("gchp") 2000 times and fails on the first duplicate. The suffix is 8 hex characters, 32 bits from crypto/rand, so the test asserts something entropy does not guarantee.
Expected rate. The birthday bound for n = 2000 draws from 2^32 is n²/2^33 ≈ 4.7 × 10⁻⁴, about one run in 2150.
Measured rate.go test ./cmd -run '^TestJobArrayIDSuffixIsNotTheClock$' -count=20000 on main (5b6e1d3, darwin/arm64) failed 6 times in 20000, for example:
generateJobArrayID produced "gchp-20261015-fd0bd6b1" at both call 724 and call 1066.
generateJobArrayID produced "gchp-20261015-0f99d9b3" at both call 277 and call 1368.
The duplicates are far apart (call 724 and call 1066). A coarse clock would repeat on consecutive calls, so these are true random collisions, not the #710 failure.
Does the suffix need widening for production?
I don't think so. Two job-array ids collide only if all three parts match: the same --job-array-name, the same YYYYMMDD, and the same 32-bit suffix. For k launches sharing a name on one day, P ≈ k²/2^33:
100 launches: about 1.2 × 10⁻⁶
1000 launches: about 1.2 × 10⁻⁴
The consequence of a collision is serious, because #691 made the RunInstances ClientToken derive from this id. But the date component already limits the window to a day, which roughly matches EC2's ClientToken idempotency window. Widening would also change the id's length and format, which appears in tags, DNS group registration and spawn array output, for no measurable gain.
Fix
Fix the test, not the id. Its purpose is to detect a clock-derived suffix. A clock-derived suffix duplicates massively: hundreds of repeats in 2000 calls on darwin's microsecond clock, and deterministic repeats on the ~16.8 ms wrap. Entropy duplicates almost never: the chance of two or more collisions in 2000 draws is about λ²/2 ≈ 1.1 × 10⁻⁷. So the test should fail on more than one duplicate, not on the first.
Activity
Stop TestJobArrayIDSuffixIsNotTheClock flaking on a random collision (#…
Stop TestJobArrayIDSuffixIsNotTheClock flaking on a random collision (#…