UNIMOODLE / moodle-local_notificationsagent

Unimoodle L5 P4
Other
3 stars 2 forks source link

Query design flaw in Courseend condition. #119

Open juacas opened 1 month ago

juacas commented 1 month ago

Courseend condition uses a query with wrong API or a bad query (duplicate value in key).

Also uses 104 dbqueries in a server with a few courses and users.

Please check both.

Courseend start
++ Did you remember to make the first column something unique in your call to get_records? Duplicate value '40' found in column 'contextid'. ++
* line 1407 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
* line 339 of /local/notificationsagent/classes/notificationsagent.php: call to mysqli_native_moodle_database->get_records_sql()
* line 222 of /local/notificationsagent/classes/notificationsagent.php: call to local_notificationsagent\notificationsagent::get_all_courses_by_ruleid()
* line 61 of /local/notificationsagent/condition/courseend/classes/task/courseend_crontask.php: call to local_notificationsagent\notificationsagent::get_conditions_by_plugin()
* line 405 of /lib/classes/cron.php: call to notificationscondition_courseend\task\courseend_crontask->execute()
* line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
* line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
* line 80 of /admin/cron.php: call to core\cron::run_main_process()
++ Did you remember to make the first column something unique in your call to get_records? Duplicate value '40' found in column 'contextid'. ++
* line 1407 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
* line 339 of /local/notificationsagent/classes/notificationsagent.php: call to mysqli_native_moodle_database->get_records_sql()
* line 222 of /local/notificationsagent/classes/notificationsagent.php: call to local_notificationsagent\notificationsagent::get_all_courses_by_ruleid()
* line 61 of /local/notificationsagent/condition/courseend/classes/task/courseend_crontask.php: call to local_notificationsagent\notificationsagent::get_conditions_by_plugin()
* line 405 of /lib/classes/cron.php: call to notificationscondition_courseend\task\courseend_crontask->execute()
* line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
* line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
* line 80 of /admin/cron.php: call to core\cron::run_main_process()
Courseend end
... used 104 dbqueries
fpano commented 4 weeks ago

The issue with the query is fixed. We're looking into the queries used in the process, but as it depends on the number of cousseend conditions to find it might be pretty normal. Anyway, if possible, please, paste here the output of setting _setdebug to true inside the cron to see the queries involved.