Moodle serving incomplete javascript during cache rebuild

Moodle serving incomplete javascript during cache rebuild

by Howard Miller -
Number of replies: 3
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well.... I think that's what's happening. I was wondering if anybody who knew this part of Moodle better than me could help.

We have seen our load-balancer getting "poisoned" with incomplete versions of the Moodle javascript and css files. Wreaking havoc. This happens if we purge the Moodle caches. 

We think what is happening is that the load balancer is requesting the files while they are still being rebuilt. I've had a dig in the code and I can't find anything to make me think that sending such files is blocked while a purge is ongoing. I find this surprising but it would seem to be confirmed by the symptoms. 

An obscure but nasty bug?

Thoughts appreciated.

Average of ratings: -
In reply to Howard Miller

Re: Moodle serving incomplete javascript during cache rebuild

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Howard,

the css cache is rebuild by the first user who calls a moodle page after the cache has been purged. Maybe your restrictions are to strict and the process for building the cache is interupted or failes somehow.

A solution for this could be to purge and generate the css cache by cli. For purging there is a script "admin/cli/purge_caches.php", I am sure you know this. To build the cache you could implement a simple cli script like this:

<?php
define('CLI_SCRIPT', 1);
require_once('config.php');
require_once($CFG->libdir.'/upgradelib.php');
upgrade_themes();

and call it immediately after the purge. This will build the css cache in the cli environment which often has fewer restrictions.

Best regards
Andreas

Average of ratings: Useful (2)
In reply to Andreas Grabs

Re: Moodle serving incomplete javascript during cache rebuild

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It's an interesting thought but surely it would still be "competing" with live users accessing the site at the same time?

I'm not clear with what you mean by 'restrictions'?
In reply to Howard Miller

Re: Moodle serving incomplete javascript during cache rebuild

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators
Hi Howard,

in my opinion there shouldn't be a competing with live users. The first process that starts the build is the winner. That should be your cli if it runs immediately after the purge.
With restrictions I was referring to all kinds of limits such timeout and so on. A cli call normally does not have these restrictions.

Best regards
Andreas
Average of ratings: Useful (1)