Description
When a resend request to Infinity (or even just a large capped number) is made, this can cause a huge number of messages to be fetched from storage into memory which can cause the application to crash due to lack of memory. It's not practical to mitigate this in the storage layer
In addition even if they fit in memory without a fix to #271 this can lead to some fairly ugly behaviour where we continue to attempt to send messages to a session that's already disconnected us.
To Reproduce
- Send several thousand messages (volume necessary dependent on application memory profile)
- Instruct the counter-party to perform a resend-request of all these messages
Expected behavior
We should fetch the messages in batches and then send them a batch at a time
System information:
N/A
Additional context
I've got a hot fix for some of this - will try to tidy it up and submit for review.
This is probably additionally key if we implement #621