Upgrading from 3.5 to 3.9 Hangs and error

Upgrading from 3.5 to 3.9 Hangs and error

by T K -
Number of replies: 11

I am upgrading my moodle from 3.5 to 3.9. I am using Centos 7 server.

Requirement checks all go fine. At the stage of plugin check & upgrading the database it consumes my server's available 6G RAM till there is only 100M RAM available. 

Is this normal?

Now my server is very slow and i cant even access any files on it.

Also I get this error after some time. What can I do to continue?

Debug info: 
Error code: sessionwaiterr
Stack trace:
  • line 1269 of /lib/dml/pgsql_native_moodle_database.php: dml_sessionwait_exception thrown
  • line 178 of /lib/classes/session/database.php: call to pgsql_native_moodle_database->get_session_lock()
  • line ? of unknownfile: call to core\session\database->handler_read()
  • line 42 of /lib/classes/session/handler.php: call to session_start()
  • line 77 of /lib/classes/session/manager.php: call to core\session\handler->start()
  • line 805 of /lib/setup.php: call to core\session\manager::start()
  • line 25 of /config.php: call to require_once()
  • line 27 of /login/index.php: call to require()

Average of ratings: -
In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

What version of Moodle is in the site's source code folder now, including the build number? For example, "3.5.16 (Build: 20210118)". This information is shown in the $release line in version.php. In that stack trace the top two lines are:

line 1269 of /lib/dml/pgsql_native_moodle_database.php: dml_sessionwait_exception thrown
line 178 of /lib/classes/session/database.php: call to pgsql_native_moodle_database->get_session_lock()

In the 3.5.x sites I've looked at the exception is thrown on line 1404:

1404                 throw new dml_sessionwait_exception();

and the call to get_session_lock() is on line 175:

175                 $this->database->get_session_lock($record->id, $this->acquiretimeout);

In 3.9.x these lines are 1460 and 176 so they still don't match the stack trace.

This suggests the either some of the source code files aren't the expected version or that they've been modified.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
Thanks for the quick reply, really appreciate it

for the 3.5 it is:
$release = '3.5 (Build: 20180517)'

for the 3.9 it is:
$release = '3.9.4+ (Build: 20210219)';

How can i resolve this?
In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The Moodle build numbers correspond to one specific source code version – everyone with that build should have exactly the same files. Consequently any errors should occur on exactly the same lines.

Your Moodle build numbers don't correspond with your stack trace with errors on lines 1269 and 178. This indicates that you have somehow got some incorrect source code files, maybe there is a mix of versions.

With Moodle version 3.5 (Build: 20180517) it's lib/dml/pgsql_native_moodle_database.php:

1404                 throw new dml_sessionwait_exception();

and lib/classes/session/database.php:

175                 $this->database->get_session_lock($record->id, $this->acquiretimeout);

With Moodle version 3.9.4+ (Build: 20210219) it's lib/dml/pgsql_native_moodle_database.php:

1460                 throw new dml_sessionwait_exception();

and lib/classes/session/database.php:

176                     $this->database->get_session_lock($record->id, $this->acquiretimeout);
You need to be certain the source code files are correct for the Moodle version in use, here are some steps for doing this.
In reply to Leon Stringer

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
Hi Leon, the link you attached is the same steps as i did, backup the old moodle, copy in a new moodle version and plug in the config.php into that.

How do i resolve the problem of incompatibility?
In reply to Leon Stringer

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
this is the Moodle 3.5 distribution itself, if this is not compatible to upgrade to 3.9, what is?

I am just wondering what are my options?
In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
i went a step back and upgraded to 3.7 this time. I get the same screen that hangs for >30mins and just nothing happens.

i really hope someone can help me there.eee

In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
I also see these errors in PHP 7.2

[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \mod_questionnaire\task\cleanup* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\question_preview_cleanup_task* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \mod_questionnaire\task\cleanup* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\question_preview_cleanup_task* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \mod_questionnaire\task\cleanup* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\question_preview_cleanup_task* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \mod_questionnaire\task\cleanup* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\question_preview_cleanup_task* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \mod_questionnaire\task\cleanup* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\question_preview_cleanup_task* line 291 of /lib/classes/task/manager.php: call to debugging()
[27-Feb-2021 10:18:11 Asia/Kuala_Lumpur] PHP Notice: Failed to load task: \core\task\clean_up_deleted_search_area_task* line 254 of /lib/classes/task/manager.php: call to debugging()


[27-Feb-2021 10:35:01 Asia/Kuala_Lumpur] Default exception handler: Site is being upgraded, please retry later. Debug:
Error code: upgraderunning
* line 494 of /lib/setuplib.php: moodle_exception thrown
* line 688 of /lib/setup.php: call to print_error()
* line 29 of /config.php: call to require_once()
* line 33 of /admin/cli/cron.php: call to require()
In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -
Im pursuing this and i noticed it hangs at this page for more than 30mins. It takes up to 10G RAM & 5G of diskspace while it hangs here, and nothing really happens on the upgrade page. Is this normal? When upgrading from 3.5 to 3.7.
In reply to T K

Re: Upgrading from 3.5 to 3.9 Hangs and error

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

You can upgrade from Moodle 3.5 to 3.9 if the server meets the requirements for Moodle 3.9, for example: PHP 7.2, 7.3 or 7.4 is installed.

I think the errors in the log are because the cron is running with the new source code present but the upgrade isn't complete. For example, question_preview_cleanup_task was not present in Moodle 3.5 but is present in Moodle 3.7 onwards.

If the upgrade doesn't seem to complete maybe PHP's max_execution_time is being exceeded. The easiest way to resolve this is to run the upgrade from the command line. See the documentation for details but this is a case of:

# cd /PATH/TO/moodle
# sudo -u apache php admin/cli/upgrade.php

Where /PATH/TO/moodle is the location of the Moodle source code and apache is the user that PHP is run as for your web server (on some servers this may be php-fpm or nginx).

The VIRT column in top isn't the amount of RAM a process takes. mysqld has more storage in VIRT than available RAM on the server. It's using 2.9 GB RAM (RES), and the server isn't using swap space (KiB Swap: … 0 used) so that looks normal and healthy to me.

In reply to Leon Stringer

Re: Upgrading from 3.5 to 3.9 Hangs and error

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

In your original post the error is:

Debug info:
Error code: sessionwaiterr
Stack trace:

    line 1269 of /lib/dml/pgsql_native_moodle_database.php: dml_sessionwait_exception thrown
    ⋮

pgsql_native_moodle_database.php means the site is using PostgreSQL ($CFG->dbtype = 'pgsql'). But your screenshot shows mysqld. So what are you using: PostgreSQL or MySQL (or MariaDB)?

In reply to Leon Stringer

Re: Upgrading from 3.5 to 3.9 Hangs and error

by T K -

this is funny, i am using mysql, not postgres