I was just trying to debug something in cron, and saw that the cron seemed to be repeately trying to delete unassign the same student enrolments.
Looking into this, its the code which is trying to unenrol users who haven't been seen in $CFG->longtimenosee. This seems to be determined from user_lastaccess.
When we unassign users using role_unassign, we don't remove the records from user_lastaccess.
So at every cron where cleanup is triggered, we keep trying to unassign the same roles, again again and again..
I don't know if the solution to this problem is to cleanup from user_lastaccess withing the role assignment functions, or do something more manual?