by Randy Thornton.
I suspect you are correct about that: these tasks are orphaned for some reason.
There are some interesting discussions in the forums about different causes of this error: eg. https://moodle.org/mod/forum/discuss.php?d=381910 and https://moodle.org/mod/forum/discuss.php?d=346326
If the relevant courses 465 and 21 are definitely deleted from the recycle bin (check in the table mdl_tool_recyclebin_course) but the course module in question still exist in the then this could be caused by something else. In the two forums above there was an issue in the cron due to the presence of other plugins such that these tasks did not get processed as they should.
To see the details of how this works, take a look at this tracker where the process was hashed out right after the recycle bin came along in core: https://tracker.moodle.org/browse/MDL-54751
There are some interesting discussions in the forums about different causes of this error: eg. https://moodle.org/mod/forum/discuss.php?d=381910 and https://moodle.org/mod/forum/discuss.php?d=346326
If the relevant courses 465 and 21 are definitely deleted from the recycle bin (check in the table mdl_tool_recyclebin_course) but the course module in question still exist in the then this could be caused by something else. In the two forums above there was an issue in the cron due to the presence of other plugins such that these tasks did not get processed as they should.
To see the details of how this works, take a look at this tracker where the process was hashed out right after the recycle bin came along in core: https://tracker.moodle.org/browse/MDL-54751