General help

Error writing database No access to course after error in image upload

 
 
Picture of Mike Kaufmann
Error writing database No access to course after error in image upload
 

Hello,  

I see the error report but do not know how to fix it.  After uploading a small image file to a label I received a database error. It reads as though the file was larger than the allowed upload size.  This is not true.  Can anyone help me with this?  I can no longer access the course. 

Running: 

Moodle 2.4.1+ (Build: 20130308) 

MYSQL 5.5.25a  and phpMyAdmin

On Mac OSX  Mountain Lion

PHP.ini was always set to allow uploads of 200MB.

Any help would be grealty appeciated. 

Thank you,

Mike

Here is the DEBUG Report...

Error writing to database
Debug info: Got a packet bigger than 'max_allowed_packet' bytes
UPDATE mdl_course SET modinfo = ?,sectioncache = ? WHERE id=?
[array (
0 => 'a:42:{i:1719;O:8:"stdClass":11:{s:2:"id";s:2:"87";s:2:"cm";s:4:"1719";s:3:"mod";s:5:"forum";s:7:"section";s:1:"0";s:9:"sectionid";s:3:"188";s:6:"module";s:1:"9";s:5:"added";s:10:"1360865466";s:7:"visible";s:1:"1";s:10:"visibleold";s:1:"1";s:15:"conditionsfield";a:0:{}s:4:"name";s:10:"News forum";}i:2143;O:8:"stdClass":13:{s:2:"id";s:3:"481";s:2:"cm";s:4:"2143";s:3:"mod";s:5:"label";s:7:"section";s:1:"1";s:9:"sectionid";s:3:"242";s:6:"module";s:2:"12";s:5:"added";s:10:"1362766613";s:7:"visible";s:1:"1";s:10:"visibleold";s:1:"1";s:5:"extra";s:21541:"<div class="no-overflow"><p><img style="display: block; margin-left: auto; margin-right: auto;" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCADLASwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/  

THIS RUNS FOR PAGES AND THEN ENDS WITH


Error code: dmlwriteexception
Stack trace:
line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1213 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1245 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
line 1409 of /lib/modinfolib.php: call to mysqli_native_moodle_database->update_record()
line 249 of /lib/modinfolib.php: call to rebuild_course_cache()
line 1341 of /lib/modinfolib.php: call to course_modinfo->__construct()
line 1000 of /lib/completionlib.php: call to get_fast_modinfo()
line 47 of /report/progress/lib.php: call to completion_info->get_activities()
line 2457 of /lib/navigationlib.php: call to report_progress_extend_navigation_course()
line 1133 of /lib/navigationlib.php: call to global_navigation->add_course_essentials()
line 2918 of /lib/navigationlib.php: call to global_navigation->initialise()
line 766 of /lib/pagelib.php: call to navbar->has_items()
line 4 of /theme/anomaly/layout/general.php: call to moodle_page->has_navbar()
line 804 of /lib/outputrenderers.php: call to include()
line 734 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
line 230 of /course/view.php: call to core_renderer->header()
Warning: Error while sending QUERY packet. PID=723 in /Library/WebServer/Documents/moodle/lib/dml/mysqli_native_moodle_database.php on line 1212 Call Stack: 0.4929 28577648 1. default_exception_handler() /Library/WebServer/Documents/moodle/lib/setuplib.php:0 0.5187 32057136 2. moodle_database->__destruct() /Library/WebServer/Documents/moodle/lib/dml/moodle_database.php:0 0.5187 32057168 3. mysqli_native_moodle_database->dispose() /Library/WebServer/Documents/moodle/lib/dml/moodle_database.php:146 0.5187 32057264 4. moodle_database->dispose() /Library/WebServer/Documents/moodle/lib/dml/mysqli_native_moodle_database.php:420 0.5187 32057640 5. session_stub->write_close() /Library/WebServer/Documents/moodle/lib/dml/moodle_database.php:347 0.5187 32057720 6. session_write_close() /Library/WebServer/Documents/moodle/lib/sessionlib.php:260 0.5188 32074416 7. database_session->handler_write() /Library/WebServer/Documents/moodle/lib/sessionlib.php:260 0.5189 32086592 8. mysqli_native_moodle_database->update_record_raw() /Library/WebServer/Documents/moodle/lib/sessionlib.php:741 0.5192 32099616 9. mysqli->query() /Library/WebServer/Documents/moodle/lib/dml/mysqli_native_moodle_database.php:1212

 

 
Average of ratings: -
Picture of Lawrence Ng
Re: Error writing database No access to course after error in image upload
 

max_allowed_packet is set in mysql config (my.cnf), NOT ON php side (ie. php.ini)

log into your sql database and check your max allowed packet size:

sql> SHOW VARIABLES LIKE 'max_allowed_packet';

In your my.cnf file, increase the size of max_allowed_packet to say 32MB (or greater than waht your database's settings are)

[mysqld]

max_allowed_packet=32M

restart your mysql services and try again

PS. You don't really need 32M ... 16M should be fine too..

 

 
Average of ratings: -
Picture of Lawrence Ng
Re: Error writing database No access to course after error in image upload
 

my.cnf file

[mysqld]
max_allowed_packet=32M

 
Average of ratings: -
Picture of Mike Kaufmann
Re: Error writing database No access to course after error in image upload
 

That was it.  Thank yuio very much for setting me in the right direction.  

 
Average of ratings: -
Picture of Lawrence Ng
Re: Error writing database No access to course after error in image upload
 

No problem Mike.

You also may want to tweak another parameter if you are using a lot of form fields.

Increase the max_input_vars in php.ini

This PHP configuration limits the maximum number of fields to post in a form: 1000 for max_input_vars

Increase it to somethin large like:

max_input_vars=19980

By doing this, it will prevent you from getting the error:

"Warning, your PHP configuration limits the maximum number of fields to post in a form: 1000 for max_input_vars."

 

 

 

 

 
Average of ratings: -
Picture of Lawrence Ng
Re: Error writing database No access to course after error in image upload
 

Did you try my suggestion? Is it working for you now?

 
Average of ratings: -