Perhaps MDL-71909, huge amount of PDF to PNG conversions? Die you try reload (Ctrl-R)?
If Moodle can not recover, you have to restore the backup and retry the upgrade on the command line.
BTW, 4.0.9 > 4.1.9 LTS is a major upgrade. https://docs.moodle.org/401/en/Upgrading
If Moodle can not recover, you have to restore the backup and retry the upgrade on the command line.
BTW, 4.0.9 > 4.1.9 LTS is a major upgrade. https://docs.moodle.org/401/en/Upgrading