For a while now Chrysanthemum has been plagued by a deadlock in message edit filtering. I've only now had the time to sit down and figure out what's going on. Essentially, Chrysanthemum, after filtering a message edit, locks up completely, sometimes. The sequence of events looks something like:
A user edits a message to something that will be filtered.
Chrysanthemum picks up the edit and tries to gather all the information from the cache.
If it succeeds, it holds a reference to the cached data for the duration of message filtering.
If the message is deleted, the Discord API could respond quickly enough for the cache to be updated before the deletion HTTP request completes.
The fix is to clone data out of the cache, so that we don't hold a reference to it for very long. This is unfortunate for efficiency reasons, but we can live with it.
For a while now Chrysanthemum has been plagued by a deadlock in message edit filtering. I've only now had the time to sit down and figure out what's going on. Essentially, Chrysanthemum, after filtering a message edit, locks up completely, sometimes. The sequence of events looks something like:
dashmap
implementation to deadlock.The fix is to clone data out of the cache, so that we don't hold a reference to it for very long. This is unfortunate for efficiency reasons, but we can live with it.