Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The database query optimization is necessary #2683

Open
drink-uj opened this issue Oct 17, 2024 · 0 comments
Open

The database query optimization is necessary #2683

drink-uj opened this issue Oct 17, 2024 · 0 comments

Comments

@drink-uj
Copy link

After running the cron process to sync Moodle courses with Microsoft Teams, I get this result (for Postgresql):

Execute scheduled task: Create user groups in the Microsoft 365 package (local_o365\task\coursesync) 
... started 13:07:00. Current memory use 34.0 MB. Debugging increased temporarily due to faildelay of 61440 Start syncing courses. Tenant has education license: yes Restore groups that have been soft-deleted... 
Processing courses without groups... 
... All courses have groups created. Processing courses without teams... 
... All courses have teams created. Updating teams cache... 
... Building existing teams cache records 
... Updating teams cache records 
... Deleting old teams cache records Cleaning up teams connection records... .
.. used 111066 dbqueries ... used 575.33459806442 seconds Scheduled task failed: Create user groups in the Microsoft 365 package (local_o365\task\coursesync), Database write error Debug info: number of parameters must be between 0 and 65535 DELETE FROM mdl_local_o365_objects WHERE type = 'group' AND subtype IN ('classteam', 'teamfromgroup') AND objectid NOT IN (VALUES ($1::text),($2::text),($3::text),($4::text),($5::text),($6::text),($7::text),($8::text),($9::text),($10::text),($11::text),"

the problem is this code:
/local/o365/classes/feature/coursesync/main.php

public function cleanup_teams_connections() {

[...]
               // If there are records in teams cache, delete teams connection records with object IDs not in the cache.
            [$teamobjectidsql, $params] = $DB->get_in_or_equal($teamobjectids, SQL_PARAMS_QM, 'param', false);
            $DB->delete_records_select('local_o365_objects',
                "type = 'group' AND subtype IN ('classteam', 'teamfromgroup') AND objectid {$teamobjectidsql}", $params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant