Skip to content

CacheRef does not document how it should not be carried over an await point #3425

@Gaming32

Description

@Gaming32

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsRelated to documentation.good first issueAn easy problem suited for people new to Rust or Serenity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions