Skip to content

[fix] Made shardless cluster not cause an assertion error when getting destroyed - #1639

Open
Henonicks wants to merge 1 commit into
brainboxdotcc:devfrom
Henonicks:destructor-fix
Open

[fix] Made shardless cluster not cause an assertion error when getting destroyed#1639
Henonicks wants to merge 1 commit into
brainboxdotcc:devfrom
Henonicks:destructor-fix

Conversation

@Henonicks

Copy link
Copy Markdown
Contributor

After cluster.cpp:162 happens, executing cluster.cpp:163 causes the assertion fail. This also works the other way around.

Shutting down the cluster (dpp::cluster::shutdown) before cluster.cpp:162 or the destruction of the object makes the assertion fail go away.

The issue isn't caused by dpp::request_queue::~request_queue directly. This destructor marks queues as terminating which doesn't let new requests come in. Yet after dpp::cluster::tick_timers has already been called so it needs to, well, tick all the timers. The timer queue can end up depleting before tick_timers finishes its job since in the while (true) loop (matching do at timer.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 the do, at timer.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 exits tick_timers if 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

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

…dless cluster doesn't cause an assertion failure
@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit e734c1d
🔍 Latest deploy log https://app.netlify.com/projects/dpp-dev/deploys/6a788f195e391100080c22f0
😎 Deploy Preview https://deploy-preview-1639--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the code Improvements or additions to code. label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code Improvements or additions to code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant