Borrow/nap-time read race causes late and early wakeups

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Workload Resilience
    • ALL
    • WR Prioritized list
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      consumeWithBorrowNonBlocking performs the borrow as one atomic CAS, then timeWhenBucket(rate, 0) re-reads zeroTime() to compute the nap time. In the window between these two operations, a later borrow can push zeroTime further into the future causing this waiter to inherit the later borrower's wake time (late wakeup, synchronized with the later borrower). Conversely, a concurrent returnTokens (from interrupt cleanup, reconcileTokens, or explicit return) pulls zeroTime back, underestimating the nap and causing the waiter to wake before its reservation matures, resulting in silent over-admission.

      We already have a fix for this: returnTokensImpl returns zeroTimeNew (the borrow's linearization point) but returnTokens discards it and the caller re-reads. Plumbing that return value up and using it as debtPaid makes the nap time race-free, eliminating both the early-wake over-admission and the pairwise synchronization.

            Assignee:
            Unassigned
            Reporter:
            Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: