[MDEV-3890] Server crash inserting record on a temporary table after truncating it Created: 2012-11-28  Updated: 2013-01-26  Due: 2013-01-24  Resolved: 2013-01-26

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.0, 5.5.28
Fix Version/s: 10.0.1, 5.5.30

Type: Bug Priority: Critical
Reporter: Risato Stefano Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: Aria

Attachments: File my.ini    

 Description   

As in summary, the commands below crash the server. I attach my configuration file if it can help.

mysql> create temporary table tmp.pippo select * from config;
Query OK, 1 row affected (0.09 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> truncate table tmp.pippo;
Query OK, 0 rows affected (0.09 sec)

mysql> insert into tmp.pippo select * from config;
ERROR 2013 (HY000): Lost connection to MySQL server during query



 Comments   
Comment by Elena Stepanova [ 2012-11-28 ]

Hi,

Could you please also provide SHOW CREATE TABLE for the `config` table?

Thanks.

Comment by Risato Stefano [ 2012-11-28 ]

I did more tests. Fresh installation of 5.5.28 both in Windows (Seven) and Linux (Ubuntu 12.04). The problem occurs using Aria as default engine, when I add the line

[mysqld]
default-storage-engine = Aria

in my.ini / my.cnf.
It's independend from the source table, here a more generic example:

MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use test;
Database changed
MariaDB [test]> create temporary table test1 select 'ciao' as field1;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

MariaDB [test]> truncate table test1;
Query OK, 0 rows affected (0.08 sec)

MariaDB [test]> insert into test1 select 'ciao' as field1;
ERROR 2013 (HY000): Lost connection to MySQL server during query

Comment by Elena Stepanova [ 2012-11-28 ]

Thank you for the report. Reproducible as described.

set default_storage_engine = Aria;

create temporary table test1 select 'ciao' as field1;
truncate table test1;
insert into test1 select 'ciao' as field1;

No crash on 5.2 and 5.3.

Comment by Jani Tolonen [ 2013-01-23 ]

A bit more simple test case to reproduce the problem:

CREATE TEMPORARY TABLE t1 ( i int) ENGINE=maria;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (1);

More information about the problem:

segmentation fault happens in ma_loghandler.c because transaction struct TRN is 0x0 (null pointer). TRN is an element of HA_MARIA table handler struct.The same problem does not occur if one does DELETE FROM t1, because it takes a different route in the code and TRN is a valid variable in that case. The problem occurs because truncate sets TRN to a null pointer value and after that insert fails with seg fault because it tries to access the not valid variable in the struct.

Comment by Jani Tolonen [ 2013-01-23 ]

Assigned to Monty after discussion.

Comment by Michael Widenius [ 2013-01-25 ]

The problem is probably that temporary tables should not be transactional and somehow truncate makes it transactional.
I plan to have this fixed today and pushed tomorrow.

Comment by Michael Widenius [ 2013-01-26 ]

Fix pushed into 5.5 tree

Generated at Thu Feb 08 06:52:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.