Commit d1e898e
committed
Order a review's timeline by attempt, because ULIDs are a coin flip
CI failed on a test that passes here: the checkpointing runner's record of a
call that answered and then died. Chasing it found a real ordering bug rather
than a flaky test.
Every row a single call writes shares one startedAt, and the timeline was
ordered by (startedAt, id) with ULID ids as the tiebreak. ULIDs are not
monotonic inside a millisecond. Measured over twenty thousand pairs, the second
of two generated in the same millisecond sorts before the first 9,594 times out
of 19,198, so one call's rows came back in a random order and the assertion
about which row held the usage was a coin flip.
Ordering is by attempt within a timestamp now, which is what the sequence
actually is. A test pins it, and reproducing the old ordering fails that test in
eight runs out of twelve, which is the honest shape of the bug: frequent enough
that CI caught it, rare enough that twelve local runs of the original test did
not.
Worth recording rather than just fixing, because the same trap applies anywhere
a ULID is used to break a tie inside one timestamp.1 parent 63f1de3 commit d1e898e
3 files changed
Lines changed: 44 additions & 2 deletions
File tree
- docs
- src/server/db/repositories
- tests/server/db
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
134 | | - | |
| 144 | + | |
135 | 145 | | |
136 | 146 | | |
137 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
0 commit comments