Bug #6712 4.1 Client drivers Segfault - or malformed packets
Submitted: 19 Nov 2004 1:49 Modified: 29 Dec 2004 6:37
Reporter: Jacques Amar Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.7 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[19 Nov 2004 1:49] Jacques Amar
Description:
The clients connections to Server 4.1.7 would segfault or give malformed packet errors AND slowly corrupt tables with updates.

The problem would appear after an INSERT. The statement:
"select * from tablename" would segfault, both in mysql client on host, remote and through perl DBI DBD::connection.

40 client linux server talking to a server exhibited this bahviour. A quick serach on the net showed I wasn't alone.

The solution was to regress the server back to 4.0.22

How to repeat:
Slow table (server) corruption on INSERTS.

Suggested fix:
Had to regress both clients and server to 4.0
[19 Nov 2004 21:33] Hartmut Holzgraefe
Can you please add a little more information to this report?

E.g. are you using FULLTEXT indexes in the tables you insert to?
[19 Nov 2004 21:41] Jacques Amar
The tables did not have anything in particualr. The first one to go was:
CREATE TABLE `site` (
  `site_id` int(11) NOT NULL auto_increment,
  `name` varchar(255) default NULL,
  `image` varchar(255) default NULL,
  `status` enum('active','deleted','pending') NOT NULL default 'pending',
  `url` varchar(255) default NULL,
  `old_id` char(2) default NULL,
  `created` int(11) unsigned NOT NULL default '0',
  `feature` int(1) NOT NULL default '0',
  `category_id` int(11) default NULL,
  `height` int(11) default NULL,
  `width` int(11) default NULL,
  `phrase` text,
  `homepage` varchar(255) default NULL,
  `second` varchar(255) default NULL,
  `third` varchar(255) default NULL,
  `fourth` varchar(255) default NULL,
  `fifth` varchar(255) default NULL,
  `urlext` enum('com','net') NOT NULL default 'com',
  `phrase1` varchar(255) default NULL,
  `phrase2` varchar(255) default NULL,
  `phrase3` varchar(255) default NULL,
  `phrase4` varchar(255) default NULL,
  `joinpage` varchar(255) default NULL,
  `long_description` text,
  `phrase5` varchar(255) default NULL,
  `phrase6` varchar(255) default NULL,
  `hg` int(1) unsigned NOT NULL default '0',
  `site_type` enum('standard','exclusive') default 'standard',
  `access_type` char(1) default 'B',
  `access_id` tinyint(1) unsigned default NULL,
  `site_alias` varchar(64) default NULL,
  PRIMARY KEY  (`site_id`),
  UNIQUE KEY `old_id` (`old_id`),
  KEY `category_id` (`category_id`)
) ;
After an INSERT
select * from site
would segfault - where as 
select * from site limit 10000000;
would work fine

Other tables got packet errors. Tried with 4.0 client AND 4.1 clients.

Major software interface uses perl. Tried the latest DBD::mysql and older versions.

The problem seems to be at the server side. I simply reinstalled 4.0.22 and ALL problems went away, with all clients.

This was a production system, so I couldn't afford to keep it alive to test more
[20 Nov 2004 14:47] MySQL Verification Team
I have tried with empty table and it works for me just fine.

Can you upload a table that crashes a connection to the 'Files' category of this bug record ?????
[25 Nov 2004 9:57] Jose Miguel Pérez Ruiz
Please, I want to comment on this bug.

I also had this packet corruption issues either with Linux or Windows clients. I have come to a solution, though I don't know if this is the real solution. ;-) Either way, I think this problem is related to the compressed protocol. When I excluded the CLIENT_COMPRESS flag on the "mysql_real_connect" call, the problem go away! I will explain my problem further:

Seen on: MySQL server 4.1.4-gamma and 4.1.7-standard (LINUX, RedHat 9.0)
Linux client: libmysqlclient_r.so.14
Windows clients:
  - libmySQL.DLL (249.856 KBytes as shipped with 4.0 server, I think).
  - libmySQL.DLL (1.069.056 KBytes as shipped with 4.1.7 server).

As I'm using Windows and Linux clients and both showed this bug, I concluded this was related to the Database server, not the client libraries.

This is what happened:
I'm using InnoDB with extensive use of foreign keys. I'm linking the client libraries with my propietary C++ software.
 
A) Malformed packets:
Query:  "SELECT * FROM my_table WHERE id=1"
Result: With a fresh mySql server started, all was fine. After doing some INSERT statements, this query returned with error "Malformed packet". I have to say, a MySQL-Front end program returned the correct result.
 
B) Corrupted column names in result:
Query: "SELECT * FROM my_table"
Result: Corrupted column names in "mysql_fetch_fields(__result);" call. This was extremelly weird since doing "SELECT id, name FROM..." returned the correct column names. I though this problem is related to the A) above, since this could be also a corruption in the packets, though on a different position.
 
I hope this could be of any help.
[25 Nov 2004 10:23] Jose Miguel Pérez Ruiz
Forget about my previous quote on the compressed client protocol: The problem persisted shortly after I posted the above message.

The only way to get the clients working again (after a "malformed packet" error) is restarting the full server.

I apologize for the "false positive", although the comments on the behaviour is still correct.
[14 Feb 2005 22:54] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".