MDL-78580 report_statistics: Prevent database deadlocks when viewing

If a quiz had a long job to calculate statstics running, this would
cause pages that may also attempt a recalculation (the statistics report
page or question bank) to load very slowly, and possibly result in a
database deadlock.

This change will firstly prevent the question bank page performing
analysis calculations at all, since these are not required for this
page, which will speed up loading and prevent deadlocks on this page.

Secondly, this adds a lock to the recalcuation process so that it cannot
run twice concurrently. This will present the user with a message to
indicate that it is waiting for a running calculation until it is
complete, and eventually it will timeout with a message and debugging.
This commit is contained in:
Mark Johnson 2023-09-13 09:31:32 +01:00
parent b4c6ed3650
commit a92e5c5770
8 changed files with 413 additions and 33 deletions

View file

@ -257,10 +257,9 @@ class calculator {
}
}
$this->stats->cache($qubaids);
// All finished.
$this->progress->end_progress();
}
// All finished.
$this->progress->end_progress();
return $this->stats;
}