web-dev-qa-db-fra.com

Mysql: Aborted connection ... / ... (Vous avez une erreur de lecture des paquets de communication)

Ce message d'erreur avait été soumis plusieurs fois dans ce forum.

J'ai essayé ce qui suit sans succès.

Contexte

Il s'agit d'une application Web Symfony1/Doctrine1. L'erreur apparaît sur mon ordinateur et sur un serveur (tous deux sur Ubuntu). Au niveau du navigateur (Chrome), j'ai une erreur:

POST http://*****/administration_dev.php/utilisateur net::ERR_EMPTY_RESPONSE

enter image description here

Voici les détails de mon ordinateur:

$ uname -a
Linux Bureau 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"
$ dpkg -l |grep php
ii  libapache2-mod-php                          1:7.0+35ubuntu6                                             all          server-side, HTML-embedded scripting language (Apache 2 module) (default)
ii  libapache2-mod-php7.0                       7.0.4-7ubuntu2.1                                            AMD64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php                                         1:7.0+35ubuntu6                                             all          server-side, HTML-embedded scripting language (default)
.../...
$ dpkg -l |grep mysql-
ii  mysql-client-5.7                            5.7.13-0ubuntu0.16.04.2                                     AMD64        MySQL database client binaries
ii  mysql-client-core-5.7                       5.7.13-0ubuntu0.16.04.2                                     AMD64        MySQL database core client binaries
ii  mysql-common                                5.7.13-0ubuntu0.16.04.2                                     all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                                5.7.13-0ubuntu0.16.04.2                                     all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.7                            5.7.13-0ubuntu0.16.04.2                                     AMD64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7                       5.7.13-0ubuntu0.16.04.2                                     AMD64        MySQL database server binaries

L'erreur apparaît lorsque j'essaie de créer un nouvel utilisateur pendant le processus d'enregistrement.

Proposition essayée

# 1 Erreur de lecture des paquets de communication MySQL

$ mysql -uroot -p -e "SET GLOBAL max_allowed_packet = 1024 * 1024 * 1024;"
Enter password: 
$ mysql -uroot -p -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
Enter password: 
+--------------------+------------+
| Variable_name      | Value      |
+--------------------+------------+
| max_allowed_packet | 1073741824 |
+--------------------+------------+
$ tail -f -n0 /var/log/mysql/error.log
2016-07-24T19:41:32.736817Z 23 [Note] Aborted connection 23 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:32.906433Z 24 [Note] Aborted connection 24 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:33.056226Z 25 [Note] Aborted connection 25 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:33.212496Z 26 [Note] Aborted connection 26 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:33.363754Z 27 [Note] Aborted connection 27 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:33.516194Z 28 [Note] Aborted connection 28 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:41:33.668201Z 29 [Note] Aborted connection 29 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)

# 2 MySQL: erreur de lecture des paquets de communication

$ cat /etc/mysql/conf.d/david.cnf 
[mysqld]
sql-mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_allowed_packet = 256M
innodb_log_buffer_size = 32M
innodb_log_file_size = 2047M
$ mysql -uroot -p -e "SET GLOBAL innodb_fast_shutdown = 0;"
$ Sudo service mysql stop
$ Sudo mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bak
$ Sudo mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bak
$ Sudo service mysql start
$ tail -f -n0 /var/log/mysql/error.log
2016-07-24T19:56:02.342912Z 7 [Note] Aborted connection 7 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:02.494024Z 8 [Note] Aborted connection 8 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:02.642960Z 9 [Note] Aborted connection 9 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:02.787908Z 10 [Note] Aborted connection 10 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:02.933718Z 11 [Note] Aborted connection 11 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:03.084066Z 12 [Note] Aborted connection 12 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)
2016-07-24T19:56:03.235319Z 13 [Note] Aborted connection 13 to db: 'pfs2' user: 'pfs2' Host: 'localhost' (Got an error reading communication packets)

Je suis à court d'idées et de suggestions, donc j'appelle à l'aide ici.

Merci pour votre soutien, je vous donnerai plus d'informations si vous en avez besoin.

David.

3
David

La solution était dans le code. Il semble qu'une exception PHP exception n'a pas été gérée et l'application s'est bloquée avant de fermer une transaction SQL ouverte.

Le message d'erreur mysql peut prendre sa source dans cet état inconfortable, je ne peux pas en dire plus.

Rolando, merci pour votre temps.

0
David

Vous exécutez MySQL 5.7 avec PHP sur le même serveur. Cela me montre que votre serveur n'est pas dédié à MySQL. PHP et MySQL sont évidemment en concurrence pour la RAM) .

Je ne vois pas non plus de tentative de définition de la taille du pool de mémoire tampon InnoDB. La valeur par défaut pour innodb_buffer_pool_size est 128M (134217728).

Veuillez garder à l'esprit quelque chose à propos de max_allowed_packet . Comme le nom de la variable le suggère, c'est la taille maximale autorisée pour un paquet MySQL . Selon la documentation MySQL, le paquet MySQL ne démarre pas comme 1G. Sa taille initiale est basée sur la valeur de net_buffer_length . Le paquet MySQL se développera ensuite dynamiquement jusqu'à max_allowed_packet selon les besoins.

Vos tentatives de réglage autour du paquet MySQL seront annulées par un manque de RAM.

SUGGESTION # 1

  • Installez PHP sur un autre serveur qui peut être un serveur Web dédié.
  • Augmentez la quantité de RAM sur le serveur DB

SUGGESTION # 2

Si vous ne pouvez pas vous permettre un autre serveur, augmentez simplement RAM et la taille du pool de tampons.

SUGGESTION # 3 (FACULTATIF)

Puisque vous utilisez MySQL 5.7, vous pouvez étendre dynamiquement le pool de tampons.

Procédez comme suit pour le définir sur 2 Go:

mysql> SET GLOBAL innodb_buffer_pool_size = 1024 * 1024 * 1024 * 2;
0
RolandoMySQLDBA