A user tried to embed the same image that was posted as an attachment for the File resource in the description field. That caused a loop in the lib/filelib.php in the following lines:
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile']))
$stored_file->send_file($lifetime, $filter, $forcedownload, $options); die;
because !isset($options['sendcachedexternalfile']) was never true.
Of course at trying to reproduce the error, we got the warning that this kind of attachment is not correct way of using the resource, yet it was still possible to force the embedding.
The user succeeded to embed the image to the description twice which then resulted in a very slow response of the whole course (and impossible to turn on editing). There were 504 timeouts by php-fpm for all the included images.
While user does get a warning before doing this, I believe this is not enough to prevent user error which is then very tricky to resolve by disabling the attached files in the SQL table mdl_files.