[Nexthop][m4062nhp] Fix agent EventBase double-drive abort on graceful exit - #1492
Open
vvasavada-nexthop wants to merge 2 commits into
Open
[Nexthop][m4062nhp] Fix agent EventBase double-drive abort on graceful exit#1492vvasavada-nexthop wants to merge 2 commits into
vvasavada-nexthop wants to merge 2 commits into
Conversation
Signed-off-by: Vishrant Vasavada <vvasavada@nexthop.ai>
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.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
The agent (both hw_agent and sw_agent) could abort with a
prevLoopTidLOG(FATAL)("Driving an EventBase while it is already being driven",EventBase.cpp) at the tail of shutdown. The abort happened because shutdown was terminated inline (exit()/std::exit()) from a thread whose event base was still live -- the thrift server's event base thread insideserve(), or a thrift stream-cleanup thread. Terminating there runs at-exit handlers that destroy folly'sEventBaseManagerand re-drive the still-live event base, tripping the CHECK and turning a clean exit into a SIGABRT/coredump. This fix makes every shutdown trigger (except ifFLAGS_exit_for_any_hw_disconnectis set) converge on a single, thread-safe path: stop the services, return, letserve()unwind back tomain(), and exit from the main thread once the thrift workers are joined - never callingexit()from an event base thread. Note that we are only making this agent in split switch agent paths.Test Plan
Ran
*AgentHwAcl*tests. Without fix, saw multiplecrashes:
No crashes with fix.
Also wrote a script to be run on DUT which signals SIGTERM to sw and hw agents and also disconnects while the
serve()is live. Verified that no crash is seen with fix. But seen without fix.With fix:
Without fix: