Skip to content

Follow-ups from #807: shutdown-drain bytes missing from BytesWritten, no test of the cancel path's budget race #819

Description

@FumingPower3925

Follow-ups from the round-1 review of #807 (celeris#760), none blocking; the blocking one (a Shutdown ctx without a deadline got the 250 ms floor) is fixed in #807 itself.

  1. Bytes the shutdown drain sends are not counted. drainSends flushes with onLoopThread=true (engine/epoll/loop.go, l.flushWrites(cs, true)), which adds to l.bytesWrittenBatch; that batch is moved into bytesWritten only in run(), which has returned by the time shutdown() runs. So the bytes the drain sends never reach Metrics().BytesWritten. Passing false (the atomic path) would count them.
  2. No test covers the cancel path's race. On a cancel of StartWithContext's context the loops start draining before the watcher's Engine.Shutdown stores the budget; the drain re-reads it each 20 ms round, within the 250 ms floor. In TestShutdownSendsTheWholeResponse the handler holds the loop (sync) or asyncWG (async) for 200 ms after the cancel, so the budget is always stored before the drain starts. A drain that read the budget once at its start would pass. A test would release the handler before the watcher can run (or delay the watcher with a hook) and check the drain still extends to the budget.

(The review's third point, TestShutdownSendDrainIsBounded allowing budget + 5 s, is fixed in #807: the limit is budget + 1 s.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/engineEngine interface or implementationbugSomething isn't workingengine/epollEpoll engine specifics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions