Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-3890

Server crash inserting record on a temporary table after truncating it

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.0.0, 5.5.28
    • Fix Version/s: 10.0.1, 5.5.30
    • Component/s: None
    • Labels:

      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

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Hi,

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

            Thanks.

            Show
            elenst Elena Stepanova added a comment - Hi, Could you please also provide SHOW CREATE TABLE for the `config` table? Thanks.
            Hide
            steris Risato Stefano added a comment -

            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

            Show
            steris Risato Stefano added a comment - 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
            Hide
            elenst Elena Stepanova added a comment -

            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.

            Show
            elenst Elena Stepanova added a comment - 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.
            Hide
            jani Jani Tolonen added a comment -

            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.

            Show
            jani Jani Tolonen added a comment - 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.
            Hide
            jani Jani Tolonen added a comment -

            Assigned to Monty after discussion.

            Show
            jani Jani Tolonen added a comment - Assigned to Monty after discussion.
            Hide
            monty Michael Widenius added a comment -

            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.

            Show
            monty Michael Widenius added a comment - 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.
            Hide
            monty Michael Widenius added a comment -

            Fix pushed into 5.5 tree

            Show
            monty Michael Widenius added a comment - Fix pushed into 5.5 tree

              People

              • Assignee:
                monty Michael Widenius
                Reporter:
                steris Risato Stefano
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 1 day
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified