Repository navigation
Conversation
… other
During a hot restart the parent forwards UDP/QUIC packets it cannot
dispatch to the child over a unix datagram socket, from its main thread,
with a blocking sendmsg(). The child's main thread waits for the parent's
replies (stats merge every flush interval, listen socket hand-offs) with a
blocking recvmsg() and does not read forwarded packets while doing so.
Once the child's socket fills up, the parent blocks in sendmsg() and never
answers the child's request; both main threads then wait on each other for
good, with admin, xDS, timers and signal handling dead in both processes.
Parent: forwarded packets go through a bounded non-blocking send queue on
the UDP forwarding stream, flushed at once and retried on a short timer
while the child's socket is full. Nothing on that path blocks, sleeps or
asserts any more: a full queue drops packets, a child that is gone drops
the queue. New server.hot_restart_udp_forwarding_{datagrams,retries,dropped}
counters report it.
Child: while waiting for a parent reply it keeps servicing the UDP
forwarding socket, probes the parent for liveness and gives up after a
bounded deadline. A parent that stopped answering is written off (no more
stats merges, new listeners bind their own sockets, terminate is still
sent); a parent whose socket is gone completes the drain as terminate would.
RpcStream: the domain sockets get send/receive timeouts, a blocking receive
returns nothing after its slice instead of asserting, and a blocked send
fails after its timeout instead of hanging. The wire protocol is unchanged.
Signed-off-by: Bruno Palermo <[email protected]>
…ng-udp-forwarding Signed-off-by: Bruno Palermo <[email protected]>
…ng-udp-forwarding Signed-off-by: Bruno Palermo <[email protected]> # Conflicts: # test/server/hot_restarting_child_test.cc
…ng-udp-forwarding Signed-off-by: Bruno Palermo <[email protected]>
Signed-off-by: Bruno Palermo <[email protected]>
Signed-off-by: Bruno Palermo <[email protected]>
…he failure paths waitForParentReply() measured its deadline with absl::Now(), the wall clock; use the steady clock so a clock step cannot move it. Add tests for the listen socket and admin shutdown requests that cannot be sent, the admin shutdown request that gets no reply, the error log when a forwarded packet fails while waiting, and the parent queueing without a retry timer after shutdown(). Signed-off-by: Bruno Palermo <[email protected]>
At the end of the drain period the child completed the drains (which unpauses the inherited UDP listeners) and then sent the terminate request once, ignoring a failure. A parent whose socket was full never got the request and kept running, reading the same UDP sockets as the child. The child now retries the request from a timer, without blocking, while the parent's socket is full, and completes the drains once the parent has exited (its socket refuses our datagrams), capped at two seconds. At the cap it logs, at error level if the parent never accepted the request. Guarded by envoy.reloadable_features.hot_restart_wait_for_parent_exit. Signed-off-by: Bruno Palermo <[email protected]>
Contributor
Author
|
/retest |
…s time source With send and receive timeouts set on the domain socket, a signal interrupts a blocking sendmsg() or recvmsg() with EINTR even for handlers installed with SA_RESTART (signal(7)). Retry the send, and treat an interrupted receive like the receive timeout, instead of asserting. Measure the reply deadline with the main dispatcher's time source, which the child already has when it first waits. Signed-off-by: Bruno Palermo <[email protected]>
…t-terminate-until-parent-exits Signed-off-by: Bruno Palermo <[email protected]> # Conflicts: # source/server/hot_restarting_base.cc # source/server/hot_restarting_child.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message: hot restart: retry the terminate request and wait for the parent to exit
Additional Description:
Stacked on #47834 and kept as a draft until it lands; until then this PR's diff also shows that PR's changes (this change is the top commit only). Follow-up to the review comment on #47834 about the terminate request: #47834 (comment)
At the end of the drain period
HotRestartingChild::sendParentTerminateRequest()completed the drains, which unpauses the UDP listeners inherited from the parent, and then sent the terminate request once, ignoring a failure. If the parent was alive but not reading its domain socket (full, so the send timed out), it never got the request and kept running. Both processes then read the same UDP sockets: a packet of one of the parent's QUIC connections that the child dequeues is unknown to the child and gets a stateless reset. Even when the request is delivered, the child takes over the sockets while the parent's workers may still be reading them, until the parent actually exits.Fix, in the child only:
RpcStream::trySendHotRestartMessagetakes an optionalBlocking::Nofor the retries. No protocol change.Runtime guard:
envoy.reloadable_features.hot_restart_wait_for_parent_exit(default true); with it off the drains complete when the request is sent, as before.This is not airtight: a parent that stays wedged past the cap still runs alongside the child. Envoy has no way to stop it (the child does not know the parent's PID), so that stays with whatever launches the processes; the error log says so.
Testing:
HotRestartingChildTestgainsDrainsCompleteOnlyAfterParentHasExited(the drained callbacks, including one registered during the wait, run only when the exit probe is refused; the probe does not block),ResendsTerminateWhileParentSocketIsFull(the request is retried without blocking until accepted, then the exit is awaited),DrainsCompleteAtTheCapIfParentLingers,DrainsCompleteAtTheCapIfTerminateIsNeverAccepted,DrainsCompleteImmediatelyIfParentIsAlreadyGoneandDrainsCompleteAtOnceWhenWaitingForParentExitIsDisabled. The existing terminate tests now wait for the exit. Hot restart child, parent, base and impl tests,server_testandhotrestart_testpass.Risk Level: low (hot restart child, end of the drain period only; runtime guarded)
Testing: unit tests (new), hot restart and server tests, hot restart integration test
Docs Changes: N/A
Release Notes: minor_behavior_changes
Platform Specific Features: N/A
Runtime guard: envoy.reloadable_features.hot_restart_wait_for_parent_exit