Block_myoverview preventing upgrading to Moodle 4.0

Block_myoverview preventing upgrading to Moodle 4.0

by Frank W Aldridge -
Number of replies: 10

Hi 

When trying to upgrade to Moodle 4.0 it comes up with the error below and then reverts back to the Upgrade Plugins page - 

Upgrading to new version

block_myoverview

Error writing to database

More information about this error

×Debug info: Lock wait timeout exceeded; try restarting transaction
DELETE mysql_deltable FROM mdl_user_preferences mysql_deltable JOIN ( SELECT p.id AS pid
FROM mdl_user_preferences p
JOIN mdl_block_instances bi ON p.name IN (CONCAT('block', bi.id, 'hidden'), CONCAT('docked_block_instance_', bi.id))
WHERE blockname = ?
AND pagetypepattern = ?
AND subpagepattern = ?) mysql_subquery ON mysql_subquery.pid = mysql_deltable.id
[array (
0 => 'myoverview',
1 => 'my-index',
2 => '2',
)]
Error code: dmlwriteexception

×Stack trace:

  • line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 1167 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1704 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->execute()
  • line 1451 of /lib/db/upgradelib.php: call to mysqli_native_moodle_database->delete_records_subquery()
  • line 1479 of /lib/db/upgradelib.php: call to {closure}()
  • line 88 of /blocks/myoverview/db/upgrade.php: call to upgrade_block_delete_instances()
  • line 1082 of /lib/upgradelib.php: call to xmldb_block_myoverview_upgrade()
  • line 584 of /lib/upgradelib.php: call to upgrade_plugins_blocks()
  • line 1935 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 719 of /admin/index.php: call to upgrade_noncore()
Has anyone else seen this or have a fix?

Thanks

Average of ratings: -
In reply to Frank W Aldridge

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Ken Task -
Picture of Particularly helpful Moodlers

Really don't have an answer for ya, sorry 'bout that!   But ... maybe some leg work/pointers ...

block_myoverview

Info on the block:
https://docs.moodle.org/dev/Block_myoverview

Looks like it has something to do with Calendar.


"Error writing to database

More information about this error"

One of the items in more info about this error:

MySQL

If you're using a MySQL database for your Moodle installation, this error can be caused by the server's max_allowed_packet size being configured incorrectly. Increasing this value may resolve the issue.


So using your mysql client on server:
mysql> show variables like 'max_allowed_packet';
what does that show?

In your debug:
Lock wait timeout exceeded; try restarting transaction

mysql> show variables like '%wait%';

Since an upgrade to 4.0 is massive, what are your PHP settings for memory a script
can consume, max time for a script to run.

A php-info page at root of your site will show you those

'SoS', Ken

In reply to Ken Task

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Frank W Aldridge -
Hi Ken,

Thanks for your reply- I have increased max_allowed_packet to 100M and set innodb_lock_wait_timeout to 120

I have increased the max time to 60 and memory to 512M in my php.ini file.

Still getting the same error so will try troubleshooting again tomorrow.

Getting same error using Web and CLi

Cheers

Frank
In reply to Frank W Aldridge

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That's saying it can't get a lock... implying that something else is locking one of those tables. Point being that the above is more likely the symptom and not the cause.

I would restore from backup and try again. Make sure you don't have any non-Moodle 4 additional plugins in the code.
In reply to Frank W Aldridge

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Tim Martinez -
Picture of Plugin developers
It looks like as part of the upgrade it's executing upgrade_block_set_my_user_parent_context('myoverview', '__default', 'my-index');

On my test site it has been running for over three hours and still going. Last time I tested the upgrade I had to let it run overnight to get it to finish.

The MySQL query taking forever is:

DELETE mysql_deltable FROM mdl_user_preferences mysql_deltable JOIN ( SELECT p.id AS pid
FROM mdl_user_preferences p
JOIN mdl_block_instances bi ON p.name IN (CONCAT('block', bi.id, 'hidden'), CONCAT('docked_block_instance_', bi.id))
WHERE blockname = 'myoverview'
AND pagetypepattern = 'my-index'
AND subpagepattern = '2') mysql_subquery ON mysql_subquery.pid = mysql_deltable.id

Try modifying your MySQL settings and increase the timeouts.
Average of ratings: Useful (1)
In reply to Tim Martinez

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Frank W Aldridge -
Hi Tim,

Thanks for that advice - possibly we were being to impatient.

I started the upgrade again at about 10:00 am and checked in on it at 4:00 pm only to be greeted with this message:
!!! Error writing to database !!!
!! MySQL server has gone away

So I am going to have to figure out how to prevent the connection from dropping off - perhaps I need to move the MySQL database locally to the same server as Moodle and run the upgrade there and then move it back to the stand-alone MySQL server.

Cheers

Frank
In reply to Frank W Aldridge

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
Hi,

Any update on this?

I am facing the same problem here.

Ricardo
In reply to Ricardo Caiado

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Ken Task -
Picture of Particularly helpful Moodlers

IF exactly the same error:

"MySQL server has gone away"

that's usually an indication that MySQL/MariaDB - php settings for 'max_allowed_packet' (default 1000, I think) is too low.   Bump that to 5000 and since it's a PHP setting restart your web services ... check PHP info page then TIA ... 'try it again'! smile

'SoS', Ken


In reply to Ken Task

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Mateus Stahelin -

Hi, Ken!!!

It worked for me.

But the "max_allowed_packet" variable is from MySQL. The default value is 16M, I increased it to 128M and it worked.

Thank you very much, Ken.

In reply to Mateus Stahelin

Re: Block_myoverview preventing upgrading to Moodle 4.0

by Ken Task -
Picture of Particularly helpful Moodlers

@Mateus - you are indeed correct ... that is a MySQL variable ... not a PHP thang!   What can I say ... 'to 'err is human!' (a senior moment there!).

But glad to hear that fixed yours! smile

'SoS', Ken