Skip to content

Problem with observer course_module_updated: slows down normal actions #39

@moodleulpgc

Description

@moodleulpgc

We at ULPGC are testing exacomp block on moodle 4.5 LTS. Our aim is to use Exabis blocks as a portfolio system at ULPGC.
We have courses with many sections, and many (> two dozens) items in each section. And 200-400 students in those courses.
We have observed a tremendous slowliness when the block is installed when a teacher changes section visibility (hidden / show) o r use the bulk edit on the course page.
We have traced the problem to the exacomp/classes/observer.php in particular, function course_module_updated() triggered by any course_module_updated event in the course.

That function has a loop for every activity and every student in the course, that makes the loop very very long in time, in the order of tenths of minutes. That makes that completion of the change in visibility of a section can take eons for the teacher, AJAX interface is locked. Even worse, the effect is present even when the block is hidden at site level, not used at all but installed.
The only way to prevent the degraded performance seems to be to disable the observer function introducing an inmediate "return true" to avoid execution.

Perhaps the effect of this observer function may be moved to a task. For instance, the observer creating an adhoc task to run on background but observer function itself terminating quickly to allow AJAX action to proceed smoothly. Or marking actions in a table for an scheduled task to update block_exacomp_update_related_examples_visibilities() later, on background.

With the current observer enabled, installing the blocks implies a terrible performance penalty in large sites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions