Extension Manager Plus

MySQL server has gone away [2006] - Extension Manager Plus

MySQL server has gone away [2006]

by dimassamid » Tue Jun 18, 2024 10:13 pm

Hello,

I have an error when checking the versions of all extensions. I have 140 extensions on the forum. Checking new versions takes some time, but the database does not crash if I do it using the default phpBB tool.

General error.png

Code: Select all

SQL ERROR [ mysqli ]

MySQL server has gone away [2006]

SQL

SELECT * FROM phpbb_config_text WHERE config_name = 'extmgrplus_list_version_check'

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1031
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 211
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 353
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/phpbb/config/db_text.php
LINE: 133
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/phpbb/config/db_text.php
LINE: 68
CALL: phpbb\config\db_text->get_array()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus_common.php
LINE: 106
CALL: phpbb\config\db_text->get()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus.php
LINE: 835
CALL: lukewcs\extmgrplus\core\ext_mgr_plus_common->config_text_set()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus.php
LINE: 194
CALL: lukewcs\extmgrplus\core\ext_mgr_plus->versioncheck_save()

FILE: [ROOT]/ext/lukewcs/extmgrplus/event/listener.php
LINE: 49
CALL: lukewcs\extmgrplus\core\ext_mgr_plus->ext_manager_after()

FILE: (not given by php)
LINE: (not given by php)
CALL: lukewcs\extmgrplus\event\listener->ext_manager_after()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 214
CALL: call_user_func()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 44
CALL: Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 62
CALL: Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 46
CALL: phpbb\event\dispatcher->dispatch()

FILE: [ROOT]/includes/acp/acp_extensions.php
LINE: 387
CALL: phpbb\event\dispatcher->trigger_event()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: acp_extensions->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry

Re: MySQL server has gone away [2006]

by LukeWCS » Wed Jun 19, 2024 2:04 pm

Hello

EMP carries out the version check with exactly the same function as phpBB itself. The difference is that after the version check, EMP reads the version data from the cache and writes it into the database. And it seems that there is a problem with this step in your case.

However, I have never seen such an error message with EMP. Before writing, EMP first reads the extmgrplus_list_version_check field from the DB and at this point the MySQL server says goodbye to you, for whatever reason. I use the config_text->get function from phpBB, which executes this SQL query that can be seen in your error message. If this simple query results in such an error message, the problem is not with EMP, but somewhere else. The SQL query is a simple read query and the amount of data to be transferred is also very small, even with 140 extensions.

Which versions do you have of

EMP
PHP
phpBB

?
May the backup be with you. Always.
User avatar
LukeWCS
Registered User
Posts: 257
Joined: Mon Dec 08, 2014 12:32 pm
Location: Germany

Re: MySQL server has gone away [2006]

by dimassamid » Wed Jun 19, 2024 5:58 pm

Thank you for your reply!

EMP 2.0.1 (from GitHub)
I was previously using version 1.1.2 which had the same problem.
PHP 8.3.2
phpBB 3.3.12
db server: MySQL(i) 5.7.21
max_allowed_packet=32M

Version checking using standard phpBB tools takes ~45 seconds and completes successfully.
If I check versions with your extension, it takes ~40 seconds before the database crashes.
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry

Re: MySQL server has gone away [2006]

by LukeWCS » Wed Jun 19, 2024 7:29 pm

Okay, thanks for the versions.

To be honest: I have absolutely no idea what could be wrong, as I have never seen this error message on any of my exts, and not on any other exts either. ;) But let's see if we can find something.

First a little test, as I want to find out something specific in order to perhaps narrow down the problem a little more:
  1. Change the setting "Set check boxes:" to "Remember last state".
  2. Set the checkboxes for all enabled and disabled extensions.
  3. Save the selection using the "Save" link in the link bar above the extensions list.
Does that work, or does the same SQL error appear?
May the backup be with you. Always.
User avatar
LukeWCS
Registered User
Posts: 257
Joined: Mon Dec 08, 2014 12:32 pm
Location: Germany

Re: MySQL server has gone away [2006]

by dimassamid » Wed Jun 19, 2024 9:54 pm

Yes. This operation is performed very quickly.

I experimented on a test board. If I reduce the amount of extensions to at least 100, the waiting time decreases and everything works fine.

I contacted my hosting provider. They told me that for security reasons, MySQL servers have a timeout limit of 30 seconds.
wait_timeout = 30
Could this be the cause of the problem?

This value is global and cannot be changed. They recommend increasing the wait_timeout for the session using the site code.
SET SESSION wait_timeout = 600
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry

Re: MySQL server has gone away [2006]

by LukeWCS » Thu Jun 20, 2024 5:19 pm

dimassamid wrote: Yes. This operation is performed very quickly.
So the functions that play a role here aren't the problem at all. That's what I assumed, but I had to be sure.
wait_timeout = 30
Could this be the cause of the problem?
Not for EMP, because it doesn't have any function that would take so long to access the DB. But EMP isn't the only Ext that's running.

Okay, next test:

Since you have 2.0.1, edit the file ext\lukewcs\extmgrplus\core\ext_mgr_plus.php

Change line 194 to this:

Code: Select all

			// $this->versioncheck_save();
Then test the version check again.
May the backup be with you. Always.
User avatar
LukeWCS
Registered User
Posts: 257
Joined: Mon Dec 08, 2014 12:32 pm
Location: Germany

Re: MySQL server has gone away [2006]

by dimassamid » Thu Jun 20, 2024 11:58 pm

I commented out this line and got a similar error.

Code: Select all

SQL ERROR [ mysqli ]

MySQL server has gone away [2006]

SQL

SELECT migration_name FROM phpbb_migrations WHERE migration_name LIKE '%\\\\migrations\\\\%'

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1031
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 211
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 353
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus.php
LINE: 736
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus.php
LINE: 670
CALL: lukewcs\extmgrplus\core\ext_mgr_plus->load_migrations_db()

FILE: [ROOT]/ext/lukewcs/extmgrplus/core/ext_mgr_plus.php
LINE: 237
CALL: lukewcs\extmgrplus\core\ext_mgr_plus->get_exts_with_new_migration()

FILE: [ROOT]/ext/lukewcs/extmgrplus/event/listener.php
LINE: 49
CALL: lukewcs\extmgrplus\core\ext_mgr_plus->ext_manager_after()

FILE: (not given by php)
LINE: (not given by php)
CALL: lukewcs\extmgrplus\event\listener->ext_manager_after()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 214
CALL: call_user_func()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 44
CALL: Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 62
CALL: Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 46
CALL: phpbb\event\dispatcher->dispatch()

FILE: [ROOT]/includes/acp/acp_extensions.php
LINE: 387
CALL: phpbb\event\dispatcher->trigger_event()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: acp_extensions->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()
I installed a clean forum for experimentation. I can send you access in a private message.
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry

Re: MySQL server has gone away [2006]

by LukeWCS » Fri Jun 21, 2024 12:20 pm

Thank you for the test login. I won't get to that until the weekend though. But let's see if we can get any more information beforehand.

Interesting. The problem obviously occurs when a function is used after the version check that accesses the DB (read). It doesn't matter which one. And I can see exactly from both error messages that the error doesn't occur in the EMP code at all, but in functions that are executed by phpBB itself.

Next try: deactivate all exts except for EMP and try again. Does it work then? Oh and before the test please undo the change in ext_mgr_plus.php.
May the backup be with you. Always.
User avatar
LukeWCS
Registered User
Posts: 257
Joined: Mon Dec 08, 2014 12:32 pm
Location: Germany

Re: MySQL server has gone away [2006]

by dimassamid » Sat Jun 22, 2024 10:13 am

On the test forum all extensions are disabled. The error is the same.

There may be some problem with the server configuration. However, I need to know what exactly is wrong so that I can contact the hosting provider.
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry

Re: MySQL server has gone away [2006]

by LukeWCS » Sat Jun 22, 2024 3:31 pm

Okay, then we can assume that other exts are not involved in the problem.

I'm stuck at this point, I really have no idea what could be causing this error. Please contact your host and send the first error message in full and ask your host whether the reason for this error has been logged somewhere.
May the backup be with you. Always.
User avatar
LukeWCS
Registered User
Posts: 257
Joined: Mon Dec 08, 2014 12:32 pm
Location: Germany

Re: MySQL server has gone away [2006]

by dimassamid » Sun Jun 23, 2024 3:41 pm

In the web server logs I found entries like this:

Code: Select all

mysite.com *.*.*.* - - [23/Jun/2024:17:59:38 +0300] "GET /adm/index.php?i=acp_extensions&sid=9524de2cbb56ed14ab2ec908cfb6f80b&mode=main&action=list&versioncheck_force=1 HTTP/1.1" 503 4671 "http://mysite.com/adm/index.php?sid=9524de2cbb56ed14ab2ec908cfb6f80b&i=acp_extensions&mode=main" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" 41099253 212159:197337
The request is returned with error 503

It seems to me that the request does not have time to complete and the web server aborts the process due to a timeout. It would be great if the version checking process could be divided into several parts, as is the case with search indexing of messages. But this is a question for the engine developers... I understand that your extension only complements the basic functionality of phpBB.
dimassamid
Registered User
Posts: 51
Joined: Sat Aug 25, 2007 4:55 pm
Location: Tallinn, Estonia
Name: Dmitry