microsoft / o365-moodle

Office 365 and Azure Active Directory plugins for Moodle
GNU General Public License v3.0
180 stars 136 forks source link

Cohort sync task failure #2641

Open dragos5436 opened 6 days ago

dragos5436 commented 6 days ago

Hi there,

I am creating a new issue as instructed by @weilai-irl on https://github.com/microsoft/o365-moodle/issues/2609.

Original message:

We have been experiencing the same Cohort sync task failure as above for a while now. It seems to be a scheduled task supposed to run every day. We discovered it after upgrading to Moodle 4.4.1 last week (an update in 4.4 pushes notifications to us now about these task failures). However, after checking the logs, it looks like the task has been failing every day since July 1st for us, so probably not related to the upgrade itself. Here is a failure message example (personal data has been removed):

 Execute scheduled task: Cohort sync (local_o365\task\cohortsync)
 ... started 14:08:41. Current memory use 13.6 MB.
 Debugging increased temporarily due to faildelay of 86400
 ... Start updating groups cache.
 ...... Added group ID 9a51bfae-90f2-44dd-8515-8f5ab61d10a4 to cache.
 ...... Added group ID 9a52bb34-1e34-42c5-b106-454b8b68e247 to cache.
 ... used 89361 dbqueries
 ... used 711.84796905518 seconds
 Scheduled task failed: Cohort sync (local_o365\task\cohortsync),Error writing to database (Data too long for column 'name' at row 1
 INSERT INTO mdl_local_o365_groups_cache (objectid,name,description) VALUES(?,?,?)
 [array (
   0 => 'b4725107-2fc0-4d83-aba6-d93181b260be',
   1 => 'username1@emailaddress; username2@emailaddress; username3@emailaddress; username4@emailaddress; username5@emailaddress; username6@emailaddress; username7@emailaddress; username8@emailaddress; username9@emailaddress',
   2 => NULL,
 )])
 Debug info:
 Data too long for column 'name' at row 1
 INSERT INTO mdl_local_o365_groups_cache (objectid,name,description) VALUES(?,?,?)
 [array (
   0 => 'b4725107-2fc0-4d83-aba6-d93181b260be',
   1 => 'username1@emailaddress; username2@emailaddress; username3@emailaddress; username4@emailaddress; username5@emailaddress; username6@emailaddress; username7@emailaddress; username8@emailaddress; username9@emailaddress',
   2 => NULL,
 )]
 Backtrace:
 * line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
 * line 1482 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
 * line 1528 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
 * line 244 of /local/o365/classes/feature/cohortsync/main.php: call to mysqli_native_moodle_database->insert_record()
 * line 72 of /local/o365/classes/task/cohortsync.php: call to local_o365\feature\cohortsync\main->update_groups_cache()
 * line 60 of /local/o365/classes/task/cohortsync.php: call to local_o365\task\cohortsync->execute_sync()
 * line 410 of /lib/classes/cron.php: call to local_o365\task\cohortsync->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 186 of /admin/cli/cron.php: call to core\cron::run_main_process()

Could you please investigate the cause of this task failure and provide a solution for fixing it?

Thank you.

Moodle version: 4.4.1 Microsoft plugins version:

PHP version: 8.1 Database version: MySQL 8.0.32

To answer your question @weilai-irl, yes, I have edited the email addresses listed after '1 =>' in the array above. I'm assuming these would go under the field 'name' in the mdl_local_o365_groups_cache table. I just checked the original error message and the total length of this entry is 256 characters.

weilai-irl commented 6 days ago

Copied from https://github.com/microsoft/o365-moodle/issues/2609#issuecomment-2379385854:

Microsoft group names can take 256 character, while the Moodle database table to store the group cache can store 255. If you try to save group cache for a group with 256 characters in the name, you will see the error.