-
Notifications
You must be signed in to change notification settings - Fork 626
Description
If a channel is created using a GuildRef
from a task other than the gateway task (e.g. an event handler task), a deadlock can ensue. This is because GuildRef
wraps Ref
. If the GuildRef
is still being held when the Channel Create event is received, then serenity will attempt to update the Guild
in the cache with new channels. This will call get_mut
on the guilds
DashMap
, which may deadlock if a Ref
is already held, thus causing a deadlock if the two tasks happen to be running on the same system thread at that particular time (which depends on tokio internals).
The root cause here is attempting to hold an equivalent of a sync lock across await
boundaries. I don't really see a good fix for the root cause, but it may be good to keep an eye on xacrimon/dashmap#150.