Bot hangs after the connection to Discord as it's loading the data files for very large bots or large data set #3045

Closed
opened 2019-10-10 00:23:06 +02:00 by PredaaA · 1 comment
PredaaA commented 2019-10-10 00:23:06 +02:00 (Migrated from github.com)

Other bugs

On a very large bot, or one with a large data set, the bot hangs after the connection to Discord as it's loading the data files.
This can result in a lot of heartbeat blocked messages for up to ~10 minutes in my case (~45 seconds for @aikaterna bot, cat, and almost the same for @kennnyshiwa bot) and can also result in the bot being disconnected from Discord on startup.
In my case it results in 2-3 disconnects, and a lot of retries to launch all the shards, with sometimes one or two shards totally dead for 5mins or more when the bot is fully started.
For context when writing this issue, my bot have 6155 guilds, aika's bot 495, and kennny's bot is on 397 guilds.
I also tried to use another storage backend, MongoDB, but it was even worse, the bot was simply not able to connect to Discord.

Is there a way to rearrange Red's order of operations to load the data -> connect to Discord all the shards -> load cogs -> tell the bot it's ready and then make the bot usable or another process that would not block the bot.

# Other bugs On a very large bot, or one with a large data set, the bot hangs after the connection to Discord as it's loading the data files. This can result in a lot of heartbeat blocked messages for up to ~10 minutes in my case (~45 seconds for @aikaterna bot, cat, and almost the same for @kennnyshiwa bot) and can also result in the bot being disconnected from Discord on startup. In my case it results in 2-3 disconnects, and a lot of retries to launch all the shards, with sometimes one or two shards totally dead for 5mins or more when the bot is fully started. For context when writing this issue, my bot have 6155 guilds, aika's bot 495, and kennny's bot is on 397 guilds. I also tried to use another storage backend, MongoDB, but it was even worse, the bot was simply not able to connect to Discord. Is there a way to rearrange Red's order of operations to `load the data -> connect to Discord all the shards -> load cogs -> tell the bot it's ready and then make the bot usable` or another process that would not block the bot.
mikeshardmind commented 2019-10-19 01:45:17 +02:00 (Migrated from github.com)

I'll be reordering these events in an upcoming PR to improve various things with bot performance. Cogs should already not do anything until the bot is "ready", in events and tasks, this is a state which can and should be waited for. bot.wait_until_ready

I'll be reordering these events in an upcoming PR to improve various things with bot performance. Cogs should already not do anything until the bot is "ready", in events and tasks, this is a state which can and should be waited for. `bot.wait_until_ready`
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#3045
No description provided.