[fix] Made shardless cluster not cause an assertion error when getting destroyed - #1639
Open
Henonicks wants to merge 1 commit into
Open
[fix] Made shardless cluster not cause an assertion error when getting destroyed#1639Henonicks wants to merge 1 commit into
Henonicks wants to merge 1 commit into
Conversation
…dless cluster doesn't cause an assertion failure
✅ Deploy Preview for dpp-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
After
cluster.cpp:162happens, executingcluster.cpp:163causes the assertion fail. This also works the other way around.Shutting down the cluster (
dpp::cluster::shutdown) beforecluster.cpp:162or the destruction of the object makes the assertion fail go away.The issue isn't caused by
dpp::request_queue::~request_queuedirectly. This destructor marks queues as terminating which doesn't let new requests come in. Yet afterdpp::cluster::tick_timershas already been called so it needs to, well, tick all the timers. The timer queue can end up depleting beforetick_timersfinishes its job since in thewhile (true)loop (matchingdoattimer.cpp:66) we pop the queue and never check if it's empty. And if it's supposed to be unable to, well, that's exactly what caused this issue in the first place. The only place in that loop's function where we do check is above thedo, attimer.cpp:62. My guess is that these checks happen to be quick enough when there are no shards to cause that assertion fail before the cluster gets to shut down, though I'm not that familiar with the codebase to be able to assert a confident verdict.Either way, this PR fixes it by simply checking for the
next_timer's emptiness before accessing its.top(). Since the original check virtually instantly exitstick_timersif it succeeds and otherwise accesses the queue anyway, my addition should have no effect on a bot's functionality. Regardless, I tested it with mine for a few minutes and it ran fine.I decided to maintain the order of the calls in
dpp::cluster's destructor in case it was important for graceful exiting.Code change checklist