Messages écrits par Alain Raap

Marcus, our Moodle database is already running for years now and I am afraid this could be a legacy problem. Or the table contains too much records that the migration fails. I'm wondering what happens in this step in /lib/db/upgrade.php where my upgrade fails:

if ($oldversion < 2022020200.02) {
// Next, split question records into the new tables.
upgrade_migrate_question_table();
// Main savepoint reached.
upgrade_main_savepoint(true, 2022020200.02);
}

And in this function where it goes wrong in /lib/db/upgradelib.php:

/**
* Split question table in 2 new tables:
*
* question_bank_entries
* question_versions
*
* Move the random questions records to the following table:
* question_set_reference
*
* Move the question related records from quiz_slots table to:
* question_reference
*
* Move the tag related data from quiz_slot_tags to:
* question_references
*
* For more information: https://moodle.org/mod/forum/discuss.php?d=417599#p1688163
*/
function upgrade_migrate_question_table(): void {
global $DB;

// Maximum size of array.
$maxlength = 30000;

// Array of question_versions objects.
$questionversions = [];

// Array of question_set_references objects.
$questionsetreferences = [];

// The actual update/insert done with multiple DB access, so we do it in a transaction.
$transaction = $DB->start_delegated_transaction(); <= this is the line where the error happens <=

I have an environment where I weekly update our Moodle 4.0 (experimental) environment. This environment was upgraded from a Moodle 3.9 LTS environment. The weekly upgrade was running without problems, until the latest build I tried to upgrade to: Moodle 4.0dev+ (Build: 20220205). The upgrade to this build failed.

When I look in the upgrade logfile I see these errors:

[#######################################################

[Exception ignored in shutdown function upgrade_finished_handler: Fout bij het schrijven van de databank

Potential coding error - active database transaction detected during request shutdown:

* line 263 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->start_delegated_transaction()

* line 1308 of /lib/db/upgradelib.php: call to mysqli_native_moodle_database->start_delegated_transaction()

* line 3912 of /lib/db/upgrade.php: call to upgrade_migrate_question_table()

* line 1875 of /lib/upgradelib.php: call to xmldb_main_upgrade()

* line 196 of /admin/cli/upgrade.php: call to upgrade_core()

Anyone experiencing the same problem?

Moyenne des évaluations  -
Hi Ricardo,

Maybe Moosh could be a solution for your problem? Check command 'course-delete' here: https://moosh-online.com/commands/
You could write a script that deletes all the courses you want to be removed.
Moyenne des évaluations Useful (2)
Well, you don't want your Moodle stack running on Windows Server. Linux is the way to go. Windows is an environment less supported and choosen here. We have Moodle running on Linux Redhat 7 and it's the most stable environment I've used for an application like Moodle.
Just a tip, for questions like scaling / clustering Moodle go to https://t.me/large_scale_moodle, very interesting to follow the discussions and questions there. You can also ask your own questions in the group.
Moyenne des évaluations Useful (1)
Have you created the database user and granted privileges for this user in MySQL? Also you have to configure this user in your Moodle config.php file ($CFG->dbtype, $CFG->dblibrary, $CFG->dbhost , $CFG->dbname, $CFG->dbuser, $CFG->dbpass, $CFG->prefix).