[MDEV-5122] "Commands out of sync", "Malformed packet" or client hang up on unique key violation Created: 2013-10-10  Updated: 2018-06-06  Resolved: 2013-10-11

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 10.0.5

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-16308 Out of sync with server Closed
relates to MDEV-3798 Add EXPLAIN for UPDATE/DELETE (mwl #51) Closed

 Description   

The problems started happening from the following revision on 10.0-base-explain-slowquerylog

revno: 3711
revision-id: psergey@askmonty.org-20131007132951-lhe4earylf5m2vmp
message:
  MDEV-3798: EXPLAIN UPDATE/DELETE
  - Add support for EXPLAIN INSERT.

and are still reproducible on the current tree:

bzr version-info
revision-id: psergey@askmonty.org-20131009090746-6zfqg47elbhnquac
revno: 3715
branch-nick: 10.0-base-explain-slowquerylog
BUILD/compile-pentium-debug-max-no-ndb

The first test case is an extract from federated.federatedx test, slightly modified to work on a single server.

drop database if exists federated;
drop table if exists test.t1;
create database federated;
create table federated.t1 (a int primary key, b varchar(64))   DEFAULT CHARSET=utf8;
create table test.t1 (a int primary key, b varchar(64))  ENGINE=FEDERATED connection='mysql://root@127.0.0.1:3306/federated/t1' DEFAULT CHARSET=utf8;
insert into test.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe") on duplicate key update a=a+100;
select * from t1;

According to the federated test, the INSERT should fail with ER_DUP_KEY, but on some reason it doesn't:

MariaDB [test]> insert into test.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe") on duplicate key update a=a+100;
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0

And the following SELECT fails with "Commands out of sync":

MariaDB [test]> select * from t1;
ERROR 2014 (HY000): Received error: 2014 : Commands out of sync; you can't run this command now

The second test case is based on a fragment from rpl.rpl_sp:

drop table if exists t1;
drop function if exists fn1;
create table t1 (a int, unique(a));
 
delimiter |;
create function fn1(x int)
  returns int
begin
  insert into t1 values(x),(x);
  return 10;
end|
delimiter ;|
 
do fn1(100);

The DO command hangs. The processlist does not show any queries in the thread, but the query in the client does not finish.

If it is replaced with SELECT fn1(100), it causes an error:

MariaDB [test]> select fn1(100);
ERROR 2027 (HY000): Malformed packet


Generated at Thu Feb 08 07:01:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.