Backups fail due to "Maximum execution time" error

Backups fail due to "Maximum execution time" error

by Rebecca O'Connell -
Number of replies: 11

I am running: 

  • Moodle 2.6
  • Apache/2.2.15 (Red Hat)
  • PHP Version 5.3.3

Backups of very large courses (>2.7GB) fail with an error: 

PHP Fatal error:  Maximum execution time of 120 seconds exceeded in [path to production folder]/lib/filestorage/zip_archive.php on line 218, referer: [url]/backup/backup.php

I tried raising the max_execution_time to 1200, and phpinfo assures me that that is indeed the current max_execution_time, but I am still getting this error.

It fails on Step 4, very near the end of the backup. It will get over 90% and then just spin until it runs out of time, and when I check the error log, I see the error listed above. 

On our site, most course that get this large do so because they have large question banks with questions containing images and/or sound files.

Might adjusting other php.ini variables, such as max_input_time, help?

Average of ratings: -
In reply to Rebecca O'Connell

Re: Backups fail due to "Maximum execution time" error

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Under Admin -> Development -> Experimental -> Experimental settings, try turning on Enable new backup format. (It was designed to solve almost exactly this problem.)

In reply to Tim Hunt

Re: Backups fail due to "Maximum execution time" error

by Jan Derriks -

Having exactly the same problem here in Amsterdam. After upgrading to 2.6.1, cron fails with:

PHP Fatal error:  Maximum execution time of 120 seconds

While we did increase this time. Phpinfo() shows that the max_execution time is 5 minutes now, but somehow Moodle's cron job keeps failing with the 120 seconds error. Where is this limit set?

Changing to the experimental backup format is not the answer I was looking for.

In reply to Tim Hunt

Re: Backups fail due to "Maximum execution time" error

by Kevin Wiliarty -

Changing that setting did make the difference for me, so thanks Tim.

In reply to Rebecca O'Connell

Re: Backups fail due to "Maximum execution time" error

by Johnny Lo -

I have the exact error on Windows 2008 R2 running IIS 7 and PHP 5.4.3.  With the experimental setting I am able to get pass the backup page.  However at Restore, the mbz file is showing -432186188 bytes.

If I click on Download on the Restore page, it'll give me error saying the page cannot be display.

If I click on Manage Backup, select the one in question on the next screen to get its property pop-up, and click Download, nothing happen.  It just as if I hadn't clicked Download.

My earlier backup files, before large files are added, display positive file size like normal.

Any help?

In reply to Rebecca O'Connell

Re: Backups fail due to "Maximum execution time" error

by Chris Lewis -

We are also seeing this error while running from the cli.  We run admin/cli/automated_backups.php every night and since we switched to 2.6.3 (from 2.4.3) we started getting a PHP fatal error.  I tried changing to the new backup format that Tim suggested and they failed with the same error just in a different file (tgz_extractor.php).  I am not sure where to go from here.  I have traced back as far as the execute function in backup/util/plan/backup_execution_step.class.php and printed out ini_get('max_execution_time').  The value is as I would expect 3600 (it is set in execute_plan).  I am not sure where the 120 second setting is being set.  

The issue appears to be with course sizes (as mentioned above).  If we delete some files from the course the backup will run until it hits the next large course.  The thing that is getting me here is that this used to work in 2.4.3.  Some of the courses have been the same size since 2010.

Any idea's on where to go from here?


We are running PHP 5.5.12, Moodle 2.6.3, and MySQL 5.5.37.

In reply to Chris Lewis

Re: Backups fail due to "Maximum execution time" error

by Ken Task -
Picture of Particularly helpful Moodlers

@Chris ... On some operating systems, there is a separate php.ini for command line.   Your OS is?

'spirit of sharing', Ken

In reply to Ken Task

Re: Backups fail due to "Maximum execution time" error

by David Rogers -

I was running into a similar issue.  It turns out that apache was running php as "FastCGI," which has its own group of timeout settings above and beyond the normal php settings.. 

I found one setting in particular, FcgidBusyTimeout, that was set to 90 seconds.  Anything that took longer than 90 seconds to complete was killed and failed. 

Bumping FcgidBusyTimeout in my php.ini from 90 to 300 enabled backups to work for me.  Perhaps this might help you as well?

In reply to Chris Lewis

Re: Backups fail due to "Maximum execution time" error

by Teddy Wiphatphumiprates -

I have used Moodle2.6.2+ and had the same problem with my 2.4GB backup file until I read this web site https://tracker.moodle.org/browse/MDL-45783.

As mentioned in that web site, a constant called TIME_LIMIT_WITHOUT_PROGRESS in the core_backup_progress.class.php has been hard coded to 120  (@ line 36). Then the progress() function calls this constant at the line 205 --> set_time_limit(self::TIME_LIMIT_WITHOUT_PROGRESS);. 

That means the backup process will ignore the max_execution_time (which is 3600) you have set in the php.ini. 

There are 3 solutions you can choose to do in the core_backup_progress.class.php file located in <YOUR-MOODLE-SITE>/backup/util/progress :

  1. To change TIME_LIMIT_WITHOUT_PROGRESS constant from 120 to 3600 (or any number you want to).
  2. To change set_time_limit(0); which means no time limit See more detail @ http://us1.php.net/manual/en/function.set-time-limit.php.
  3. To use ini_get("max_execution_time") to get the max execution time from your php.ini, then change set_time_limit function to that value. I used this solution and below is what I modified in that file. 
  • $max_exec_time = ini_get("max_execution_time");
  • set_time_limit($max_exec_time);
  • //set_time_limit(self::TIME_LIMIT_WITHOUT_PROGRESS)  // Original value from Moodle

Hope this would help,

Teddy

Average of ratings: Useful (3)
In reply to Teddy Wiphatphumiprates

Re: Backups fail due to "Maximum execution time" error

by Chris Lewis -

Teddy, that is exactly what was causing it!  Thanks for the help.  I added the same code you did because it will obey whatever has been set in the ini.  Again, thanks!

In reply to Teddy Wiphatphumiprates

Re: Backups fail due to "Maximum execution time" error

by Andrew Normore -

To clarify, here's what you change to just make it work:


// set_time_limit(self::TIME_LIMIT_WITHOUT_PROGRESS); // This is a 2.6 bug,
set_time_limit(0); // Nasty hack to fix timeouts


File is found in C:\wamp\www\moodle\backup\core_backup_progress.class.php on line 204 (ish, depending on your version)

Average of ratings: Useful (2)
In reply to Andrew Normore

Re: Backups fail due to "Maximum execution time" error

by Albert Ramsbottom -

Hi


Old thread but I believe that this could be half of my problem.  I too am getting the same errors in my PHP log.  Now most of these errors are large files but not all.  I think it is more likely that its related to the amount of activities as I have had the same error on courses only 200MB


cheers