Error writing to database

Error writing to database

by jobe jobe -
Number of replies: 7

Hello - I was on 2.2.1 & on importing a course into an existing course I couldn't make a backup, getting 'Error writing to database' - so I upgraded to 2.2.2 & get the same.

Very frustrating - as I'm having to set up separate part courses so all can be backed up OK, rather than all in one course.

I have checked the db - all seems fine. 

In the cron job report, I'm sometimes getting the course backed up & sometimes not. 

On another Moodle I can import & backup without a problem. 

I see I should be turning on 'debugging' but I'm unsure where to see the results of the errors - I have access to the server files, but am not particulary savvy.

Any suggestions would be appreciated. Thanks. 

Average of ratings: -
In reply to jobe jobe

Re: Error writing to database

by jobe jobe -

I turned on debugging & I get this when I try to make a backup - & also on all other pages as well

Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/proc/loadavg) is not within the allowed path(s): (/home/me:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/me/public_html/lib/moodlelib.php on line 10003


Warning: is_executable() [function.is-executable]: open_basedir restriction in effect. File(/usr/bin/uptime) is not within the allowed path(s): (/home/me:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/me/public_html/lib/moodlelib.php on line 10006


this is what is at those lines in that document:

// Grab the load average for the last minute
// /proc will only work under some linux configurations
// while uptime is there under MacOSX/Darwin and other unices
if (is_readable('/proc/loadavg') && $loadavg = @file('/proc/loadavg')) {
list($server_load) = explode(' ', $loadavg[0]);
unset($loadavg);
} else if ( function_exists('is_executable') && is_executable('/usr/bin/uptime') && $loadavg = `/usr/bin/uptime` ) {
if (preg_match('/load averages?: (\d+[\.,:]\d+)/', $loadavg, $matches)) {
$server_load = $matches[1];
} else {
trigger_error('Could not parse uptime output!');
}
}

Not sure this is connected to the course backup problem though - I can make backups of other courses fine, just not those that have imported other courses - also happens with restore. 

Any help would be appreciated. Thanks. 

In reply to jobe jobe

Re: Error writing to database

by Guillermo Madero -

Hi Jobe,

I think the following thread is related to your problem:

http://moodle.org/mod/forum/discuss.php?d=85735

Maybe you could also disable the PHP open_basedir protection: open your php.ini file, search for the open_basedir line and comment it.

In reply to Guillermo Madero

Re: Error writing to database

by jobe jobe -

Thanks for getting back to me & the link Guillermo.

I have turned off open_basedir for this domain in whm & the above error warnings have gone when i turn on the debugging. 

Unfortunately I have still got the import within a course & then backup db problem. 

For those who find themselves with the same, I rather think it is related to the following.

http://tracker.moodle.org/browse/MDL-28963

Some of the data in the imported course is from 1.9 .....

 

 

In reply to jobe jobe

Re: Error writing to database

by Guillermo Madero -

Hi, you're welcome!

About the backup problem, it seems to me that the size of those courses is exceeding some kind of limit. You can go to: Site administration > Server > PHP info, scroll to the Core section, and see what values you have for the following parameters:

max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize

As you have access to your php.ini file, you could increase the values of these parameters (a bit of trial and error). For example, if the first two are low, your backup process might be timing-out. In my case, sometimes I have had to give the backup/restore process up to 10 minutes to complete.

In reply to Guillermo Madero

Re: Error writing to database

by jobe jobe -

Yes, I've already been down that path & all is well over the normal limits.

I tracked down a few posts that talk of 1.9 > 2.0 upgrade probs & I did indeeed upgrade like this so I think it is the old data causing some problem with the db. 

New courses in 2.0++ are backingup ok. 

In reply to Guillermo Madero

Re: Error writing to database

by Luna Llena -

I am using Moodle 2.6 and I didn't have any problem with cron until today that shows "error writing to database". I do not what to do because I checked

max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize

and the values are the same I used in  development and I do not have any problem in that Moodle.

In reply to Luna Llena

Re: Error writing to database

by Guillermo Madero -

Hi Luna,

Development and Production values should be different, that's precisely why PHP includes two templates:

  • php.ini-development
  • php.ini-production

You need to set up your production server as a production server.

 

Anyway, given the "until today" part, you also need to check and see what did you, or any other admin, changed, either in the server (software/hardware), the configuration files or within Moodle. There's always a reason from "sudden" problems.

Enable Debugging and also check the web server error log.