Database error cron.php moodle 2.6.1 - decimal precision

Database error cron.php moodle 2.6.1 - decimal precision

by Italo Valcy -
Number of replies: 0
Dear folks,

We've been seeing some problems with our cron.php rotine related to database insertion on grade_grades table, as follow:

Database transaction aborted automatically in
/var/www/moodle/admin/cli/cron.php
Default exception handler: Error writing to database Debug: Column
count doesn't match value count at row 1
INSERT INTO mdl_grade_grades
(itemid,userid,rawgrade,rawgrademax,rawgrademin,rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported,overridden,excluded,timecreated,timemodified,feedback,feedbackformat,information,informationformat)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
  0 => '2268',
  1 => '25391',
  2 => '2.7027027027027026',
  3 => '100.00000',
  4 => '0.00000',
  5 => NULL,
  6 => '2',
  7 => 2.7027027027027,
  8 => 0,
  9 => 0,
  10 => 0,
  11 => 0,
  12 => 0,
  13 => 0,
  14 => '1458559818',
  15 => 1458559819,
  16 => NULL,
  17 => 0,
  18 => NULL,
  19 => 0,
)]
Error code: dmlwriteexception
* line 444 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to
moodle_database->query_end()
* line 1122 of /lib/dml/mysqli_native_moodle_database.php: call to
mysqli_native_moodle_database->insert_record_raw()
* line 330 of /lib/grade/grade_object.php: call to
mysqli_native_moodle_database->insert_record()
* line 750 of /lib/grade/grade_grade.php: call to grade_object->insert()
* line 1725 of /lib/grade/grade_item.php: call to grade_grade->insert()
* line 284 of /lib/gradelib.php: call to grade_item->update_raw_grade()
* line 431 of /mod/checklist/lib.php: call to grade_update()
* line 389 of /mod/checklist/lib.php: call to checklist_grade_item_update()
* line 193 of /mod/checklist/autoupdate.php: call to
checklist_update_grades()
* line 663 of /mod/checklist/lib.php: call to checklist_autoupdate()
* line 282 of /lib/cronlib.php: call to checklist_cron()
* line 63 of /admin/cli/cron.php: call to cron_run()

From the best of my knowledge and based on some tests I did, it seems to be related to decimal precision of some table fields such as rawgrade, finalgrade, rawgrademin and rawgrademax. These fields has a definition of DECIMAL(10,5).

Is there anyone having the same problem? Do you have any other idea what it can be?

I've made the bellow patch proposal which apply the same approach of grade_grade::update() into grade_grade::insert()

--- lib/grade/grade_grade.php	2014-02-06 19:46:12.000000000 -0300
+++ /home/italovalcy/lib/grade/grade_grade.php	2016-03-24
09:53:59.242733556 -0300
@@ -747,6 +747,10 @@
     public function insert($source=null) {
         // TODO: dategraded hack - do not update times, they are used
for submission and grading (MDL-31379)
         //$this->timecreated = $this->timemodified = time();
+        $this->rawgrade    = grade_floatval($this->rawgrade);
+        $this->finalgrade  = grade_floatval($this->finalgrade);
+        $this->rawgrademin = grade_floatval($this->rawgrademin);
+        $this->rawgrademax = grade_floatval($this->rawgrademax);
         return parent::insert($source);
     }

Do you think it makes sense?

I apologize in advance if this is not the right place to post the above question. Meanwhile, I would appreciate if you suggest the right forum.


Regards, Italo


Average of ratings: -