Moodle
  1. Moodle
  2. MDL-9431

Repeatedly try to unenrol users who haven't logged in for $CFG->longtimenosee

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.7.2, 1.8, 1.9
    • Fix Version/s: 1.9
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      29538

      Description

      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?

        Activity

        Hide
        Dan Poltawski added a comment -

        Just verified this bug more throughly on latest cvs. The attached patch will fix it, however it wont deal with the situation up to now where by if a lastaccess entry exists for a course enrolment which doesn't exist the cron will waste time trying to unenrol these users.

        Putting the lastaccess removal in role_unassign gives the advantage of not leaving many unenrolled users lying around to attempt unenrolments though..

        Show
        Dan Poltawski added a comment - Just verified this bug more throughly on latest cvs. The attached patch will fix it, however it wont deal with the situation up to now where by if a lastaccess entry exists for a course enrolment which doesn't exist the cron will waste time trying to unenrol these users. Putting the lastaccess removal in role_unassign gives the advantage of not leaving many unenrolled users lying around to attempt unenrolments though..
        Hide
        Dan Poltawski added a comment -

        I've fixed this in CVS. But leaving this open as we need to fix existing records which haven't been deleted.

        Show
        Dan Poltawski added a comment - I've fixed this in CVS. But leaving this open as we need to fix existing records which haven't been deleted.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Raising to critical. Not sure if the patch is perfect but we should, IMO:

        Delete the user_lastaccess record once the user haven't any role in one course (i.e. when the last role is unassigned).

        Something like that. I don't know the implications.

        Show
        Eloy Lafuente (stronk7) added a comment - Raising to critical. Not sure if the patch is perfect but we should, IMO: Delete the user_lastaccess record once the user haven't any role in one course (i.e. when the last role is unassigned). Something like that. I don't know the implications.
        Hide
        Martin Dougiamas added a comment -

        I belive this is fixed now ... Petr it was you I think? or Eloy?

        Show
        Martin Dougiamas added a comment - I belive this is fixed now ... Petr it was you I think? or Eloy?
        Hide
        Petr Škoda added a comment -

        fixed properly in 1.9 during Eloy's cron perf/mem cleanup - it needed some bigger changes in cron and roles related code, I do not think it is possible to backport
        closing now, thanks!!

        Show
        Petr Škoda added a comment - fixed properly in 1.9 during Eloy's cron perf/mem cleanup - it needed some bigger changes in cron and roles related code, I do not think it is possible to backport closing now, thanks!!

          People

          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: