简体   繁体   中英

Empty row packet body mysql

I usually code at the same environment that is at my school university. Today the library is closed because of renovations so I switched library.

My queries always work at my usual library. My production environment has no problems with its queries.

Now, when using this connection at this new library, my mysql queries are whether stuck on infinite or I receive this Warning: Empty row packet body .

The only different thing that changed is the wifi connection. I'm not sure to understand how come a wireless connection can make my queries stuck on infinite or throw this error Warning: Empty row packet body .

Did any of you already experienced this or have any clue on how to solve this. First time this happens to me. At home no problem, at usual library no problem, at production server level no problem, but at this particular library, problems.

Funny thing is that when I try to ssh to my server, my connection drops.

Thanks for the help

  • OK, I'm just gonna go away from this library, seems to be throttling me with some voodoo networking magic.

EDIT Example of failing query InnoDB (1+ million table)

 SELECT 
  ST_X(cs.point) AS X, 
  ST_Y(cs.point) AS Y, 
  s.sizeFormat AS size, 
  s.size as sizeHM, 
  es.name AS estateSize, 
  cs.noLogement as estateSizeHM, 
  cs.title AS title, 
  dbr.name AS dateBuiltRange, 
  DATE_FORMAT(cs.dateBuilt, '%Y') as dateBuiltRangeHM, 
  m.myId AS meuble, 
  cs.meuble_id as meubleHM, 
  cs.captionPath AS paths, 
  DATE_FORMAT(cs.rentPriceDate, '%d-%m-%Y') as date, 
  cs.rentPrice as price 
FROM 
  CommonSummary AS cs 
  LEFT JOIN Size AS s ON (cs.size_id = s.id) 
  LEFT JOIN Meuble AS m ON (cs.meuble_id = m.id) 
  LEFT JOIN EstateSize AS es ON (cs.estateSize_id = es.id) 
  LEFT JOIN DateBuiltRange AS dbr ON (cs.dateBuiltRange_id = dbr.id) 
  LEFT JOIN City AS city ON (cs.city_id = city.id) 
  LEFT JOIN Quartier AS q ON (cs.quartier_id = q.id) 
  LEFT JOIN Arrondissement AS arr ON (cs.arrondissement_id = arr.id) 
WHERE 
  cs.validPoint = 1 
  AND cs.subCatMyId = 1 
  AND (
    cs.rentPriceDate <= '2016-06-30 23:59:59' 
    and cs.rentPriceDate >= '2016-04-01 00:00:00'
  ) 
 AND cs.rentPrice <= 2000 
 and cs.rentPrice >= 150 
 AND (cs.cityMyId = '1') 
LIMIT 
 5000

EDIT 2

MYSQL LOGS: Got an error writing communication packets

EDIT 3

I went to a coffee shop and boom, magic, it works.

Backup your database and try switching your tables engine from MyISAM to InnoDB . MyISAM locks the entire table while InnoDB do a better handling of rows being changed.

From MySQL docs: http://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html

ALTER TABLE table_name ENGINE=InnoDB;

Important

Do not convert MySQL system tables in the mysql database (such as user or host) to the InnoDB type. This is an unsupported operation. The system tables must always be of the MyISAM type.

Because it is a network issue only related to that specific environment, you can try increasing net_read_timeout and net_write_timeout when connecting from the new library:

SET @@local.net_read_timeout=600;
SET @@local.net_write_timeout=600;

It will only affect the current session, so run it just before your query. Play with the values to find what suits (if that's the case).

Refer to


mysql> show variables like "net_%_timeout";
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| net_read_timeout  | 30    |
| net_write_timeout | 60    |
+-------------------+-------+
2 rows in set (0.00 sec)

mysql> SET @@local.net_read_timeout=600;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like "net_%_timeout";
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| net_read_timeout  | 600   |
| net_write_timeout | 60    |
+-------------------+-------+
2 rows in set (0.00 sec)

Depends on how you read the tables: normally you just need

SET GLOBAL net_read_timeout = your_time_in_seconds;

if you are using cursor your engine has to be InnoDB and set these both:

SET GLOBAL net_read_timeout = your_time_in_seconds;
SET GLOBAL net_write_timeout = your_time_in_seconds;

In Laravel Projects:

DB::statement("SET GLOBAL net_read_timeout = your_time_in_seconds;");
DB::statement("SET GLOBAL net_write_timeout = your_time_in_seconds;");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM