Is it necessary to use maintenance mode for small updates?

Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
Number of replies: 14

Hello all,

I'm interested to know if it is really necessary to schedule downtime for small upgrades, like installing or updating a single plugin.

Is it just intended to keep users from experiencing an interruption? Or could problems be caused by users trying to access things and causing database read/write during the upgrade?

I just want to understand this a bit more clearly.

Average of ratings: -
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Installing a plugin... is likely to add new tables and settings that nobody can be using (because they're new). I wouldn't worry too much.

Updating a plugin - what if a user is writing data to tables at the same time as you are changing to schema or otherwise updating the table contents (if that's what the update does). Could end up with corrupt data.

If you want the "safe" answer... if you are going to do something that changes the database you should take the site offline (maintenance mode or whatever), take a backup and do the update. If you don't do that then you incur an increase in risk. How much depends entirely on what you are doing.
Average of ratings: Useful (2)
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
As Howard said, going into maintenance mode is the safest thing to do.

I will provide my own 2 cents ($US). I run my own small Moodle. Right now, four courses running with a total of around 160 students. My moodle has around 8 add-ins. Nope, I don't put my Moodle into maintenance mode when updating everything.

Here's what I do. In a temporary folder, I prepare my new (upgrade) Moodle with all these add-in, and with a copy of config.php. Then, I wait for a time when I see no students have done anything for 5 minutes (i.e., no online users.) Often, early morning before 7AM is a good time. Then, through SSH scripts, I rename my current moodle, move my prepared new moodle into the right server location, and quickly do the update. For my small Moodle (moodledata = 5GB, sql = 1.5GB) this update takes less than 3 minutes. Oh, I had already tested the new Moodle in a local MAMP environment, making sure everything new was working. So, there is a very small window (< 3 minutes) where a student might try to do something during my update. I take this risk, and so far have never had a problem (after doing my updates this way for nearly 8 years.)

Others here on Moodle.org will explain their methods.

Yes, I really don't have any problem putting Moodle into Maintenance mode, but doing so might take me, oh, 2-3 minutes, so there is not much difference. In my own instructions that I sometimes pass along to others, yep, I say "put Moodle into Maintenance mode." Sometimes I don't practice what I preach!
Average of ratings: Useful (3)
In reply to Rick Jerz

Re: Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
Hi Rick

Thanks for sharing your strategy (and being candid about what you do)...Based on your comments I looked at the CLI maintenance mode. Curious if you have tried that?
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Very good question, Ben. Actually, I am aware of the CLI maintenance mode but haven't experimented enough with it to make it be part of my normal process. However, your post is a good one and I am going to give it a try. Thanks.

Here is how I remind myself of my step #5.

5RightBeforeMove.txt
Right before move
-----------------
Check to see if any users are currently logged in. If not, you might not need
to put Moodle into Maintenance Mode. However, if you are cautious, Maintenance mode
is recommended.

There are two ways that I check.
a) Go to Dashboard. This shows all logged in users.
b) Go Admin, Users, Browse list, and sort by Last access.

1) Put moodle into maintanance mode, if desired.

I prefer to do this from within my moodle, however, this command line might work.

php admin/cli/maintenance.php --enable
Average of ratings: Useful (2)
In reply to Rick Jerz

Re: Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
Rick, I'd love to hear your thoughts if you do try it out. It looks intriguing to me because it can be scheduled and puts a warning/ countdown timer in a big red banner on the site. Good to tell users to wrap up what they are doing. My main concern with doing more frequent, small updates would be interrupting things like quiz attempts or long forum posts. I find I can communicate ahead of time with announcement posts, emails, etc but there will always be people who don't see or read it.
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by David M -

Yes, the advance warning of maintenance before enabling maintenance mode

php admin/cli/maintenance.php --enablelater=MINUTES

is a very useful option. We use it whenever we are doing maintenance.

As noted, it alerts people using the site (the ones who ignored the advance warning email about scheduled maintenance wink) that they will need to logout soon.

Average of ratings: Useful (3)
In reply to David M

Re: Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
David, thanks, I tried it on a dev server. What a great, easy step to improve transparency and alert users. My only qualm is that on the boost theme at least it's a bit understated. But I'm definitely going to use this for my next upgrade cycle.
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers
Add something like like:

.maintenancewarning {
background-color:red;
color:white;
}
to /admin/settings.php?section=themesettingboost > Advanced settings > theme_boost | scss

and no user will miss it ;).
Average of ratings: Useful (1)
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers
This probably should have been obvious for admins but using the CLI script for turning on the maintenance mode blocks the WWW interface even for admins. At least I ran the script with sudo permissions. Perhaps it should have been run using the www-data / apache server as the owner. I have not tested for that.
In reply to Przemek Kaszubski

Re: Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
Przemek, thank you for your great contributions. I tried the SCSS and it works beautifully. Saved me from having to go in and figure out what CSS classes to use smile 



And yes a good note of warning that web access to the site is totally cut off when using CLI maintenance mode. So you need to be comfortable running updates from the command line as well. Since I already use git for updates this is an easy change for me to make. Instead of visiting the admin notifications area I can just run:

##do the upgrade (using the apache user)
 $ sudo -u www-data /usr/bin/php admin/cli/upgrade.php
##turn off maintenance mode
 $ sudo -u www-data /usr/bin/php admin/cli/maintenance.php --disable
Average of ratings: Useful (1)
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Paul Raper -
As a rule I always switch to Maintenance mode when performing any kind of "Maintenance" on my sites.

It may seem like belt and braces, but I simply cannot afford to have issues due to taking short cuts.

Think of it as a few moments spent switching in or out of Maintenance mode that may save you hours or days of repairing something that has become corrupt.
Average of ratings: Useful (2)
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Ben Kahn -
Thanks, all, for the replies. To talk about my own experience: I took over admin about 9 months ago for a fairly large (5,000-ish University users) Moodle install with a lot of plugins. In that time I have done three minor Moodle version updates when they come out (3.4.4->3.4.6, then 3.4.7, finally 3.4.8). During that time I also update plugins, install any new plugins that have been requested by faculty, and make any other planned changes (like switching to SAML auth). For each of these relatively major changes, it makes sense to schedule downtime, enable maintenance mode, and make backups of everything. So far everything has gone smoothly.

Lately, I have been thinking about ideas like continuous deployment, where more frequent, smaller updates are made, and what that might look like in the Moodle world. Would it make sense to just install a single plugin, instead of holding it for weeks or even months for the next planned upgrade window? Maybe, but taking the site offline each time might be a problem.... Other than the middle of the night, there is never a time when at least 100-200 users aren't logged in.  Maybe I could set a weekly maintenance window and "train" my users not to expect to be able to access the site at that time....
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I tend to install plugins on the fly without putting into maintenance mode as a plugin install normally does not interrupt users in their daily activities.
Online users block is a much quicker way to check on active users...for interim updates, I always check that, send out a quick message or put an alert on the front page and then run when there are not a lot of users on.
I did not know about the alert from the cli maintenance mode - I am going to have to try that...
In reply to Ben Kahn

Re: Is it necessary to use maintenance mode for small updates?

by Ray Hinton -
At my organization, we also went with the "weekly" maintenance window approach. We do not always need the time, but, we made sure that we talked with various department representatives and agreed that this is the time we would use if Moodle needs to be offline.

We also distribute the communication of maintenance windows. For example, I send an email to departments or managers, who notify their respective instructors, who send emails or post announcements in their individual courses. Of course, I also post an Announcement on the site Front page, but some people might miss that.

There is certainly a balance between taking your site offline all the time, and holding on to updates until you feel you have a critical mass. For my part, I am always trying to find ways to improve my own process and make things faster (I learned a couple things from Rick's posts here!).