mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 02:31:18 -08:00
TestWriterFloodDoesNotStarveControlFrames checked that a pong queued
during a packet flood went out within a queue's depth of packets by
requiring the highest sequence number written before the pong to be at
most seqAtPong+depth. But the flood keeps the queue full, so enqueue
drops at the head (dropReasonQueueHead), and whenever the writer is
descheduled the flooder can push hundreds of newer packets through the
ring. The next packets the writer dequeues then carry sequence numbers
far past seqAtPong+depth even though it wrote no more than depth
packets before the pong, e.g.:
pong written after packet 4573; want no later than packet 4071 (pong queued at 4039, depth 32)
The server's actual guarantee is in packets written: writePending
sends a pending pong before its queue drain, and each drain pass is
capped at perClientSendQueueDepth packets, so at most depth packets
are written between queuePong and the pong. Measure that directly:
read sclient.packetsSent right after queuePong and have the fake conn
record the packet frame count when the first pong is written. Reading
packetsSent after queuePong means a preemption in the test goroutine
can only loosen the bound, never cause a false failure.
The test still guards the anti-starvation property: with writePending's
per-pass budget removed it fails every run ("pong written after 720
more packets; want at most 32"), and with the budget doubled to
2*depth it fails 11 of 20 runs.
flakestress -p 4 -taskset 0-1:
before: 1401 failures / 24665 runs (5.7%)
after: 0 failures / 45896 runs
Fixes #22347
Change-Id: Ia751bae9789d9eb9f36f978ef14088b955b58785
Signed-off-by: Brad Fitzpatrick <[email protected]>