[MCOL-1635] insert into select crashes for a BLOB column Created: 2018-08-09  Updated: 2018-08-15  Resolved: 2018-08-15

Status: Closed
Project: MariaDB ColumnStore
Component/s: MariaDB Server
Affects Version/s: 1.1.5
Fix Version/s: 1.1.6

Type: Bug Priority: Major
Reporter: Ravi Prakash (Inactive) Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

Centos 7.4


Sprint: 2018-16

 Description   

Try the following test script to reproduce the problem.

DROP TABLE if exists t1;
DROP TABLE if exists l_t1;
 
CREATE TABLE t1 ( c1 int not null, c2 bigint, c3 float,
    c4 double, c5 char(10), c6 varchar(20), c7 datetime ,
    c8 tinytext, c9 tinyblob, c10 text, c11 blob,
    c12 mediumtext, c13 mediumblob, c14 longtext,
    c15 longblob ) engine=columnstore;
 
CREATE TABLE l_t1 ( c1 int not null, c2 bigint, c3 float,
    c4 double, c5 char(10), c6 varchar(20), c7 datetime ,
    c8 tinytext, c9 tinyblob, c10 text, c11 blob,
    c12 mediumtext, c13 mediumblob, c14 longtext,
    c15 longblob ) engine=columnstore;
 
 
insert into t1 values(95000, 88000, 12.45, 99.56, 'charone', 'varcharone', '2018/07/08 10:10:10',
                      'tinytext', '<---tinyblob---->', 'a-text-type', 'a-blob',
                      'medium-text', 'medium-blob', 'long-text', 'long-blob');
select * from t1 where c1 > 0;
insert into l_t1 values(95000, 88000, 12.45, 99.56, 'charone', 'varcharone', '2018/07/08 10:10:10',
                      'tinytext', '<---tinyblob---->', 'a-text-type', 'a-blob',
                      'medium-text', 'medium-blob', 'long-text', 'long-blob');
insert into l_t1 select * from t1;
select * from l_t1 where c1 > 0;

I have the following result from running the script:

MariaDB [mydb]> desc t1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| c1    | int(11)     | NO   |     | NULL    |       |
| c2    | bigint(20)  | YES  |     | NULL    |       |
| c3    | float       | YES  |     | NULL    |       |
| c4    | double      | YES  |     | NULL    |       |
| c5    | char(10)    | YES  |     | NULL    |       |
| c6    | varchar(20) | YES  |     | NULL    |       |
| c7    | datetime    | YES  |     | NULL    |       |
| c8    | tinytext    | YES  |     | NULL    |       |
| c9    | tinyblob    | YES  |     | NULL    |       |
| c10   | text        | YES  |     | NULL    |       |
| c11   | blob        | YES  |     | NULL    |       |
| c12   | mediumtext  | YES  |     | NULL    |       |
| c13   | mediumblob  | YES  |     | NULL    |       |
| c14   | longtext    | YES  |     | NULL    |       |
| c15   | longblob    | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
15 rows in set (0.01 sec)
 
MariaDB [mydb]> desc l_t1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| c1    | int(11)     | NO   |     | NULL    |       |
| c2    | bigint(20)  | YES  |     | NULL    |       |
| c3    | float       | YES  |     | NULL    |       |
| c4    | double      | YES  |     | NULL    |       |
| c5    | char(10)    | YES  |     | NULL    |       |
| c6    | varchar(20) | YES  |     | NULL    |       |
| c7    | datetime    | YES  |     | NULL    |       |
| c8    | tinytext    | YES  |     | NULL    |       |
| c9    | tinyblob    | YES  |     | NULL    |       |
| c10   | text        | YES  |     | NULL    |       |
| c11   | blob        | YES  |     | NULL    |       |
| c12   | mediumtext  | YES  |     | NULL    |       |
| c13   | mediumblob  | YES  |     | NULL    |       |
| c14   | longtext    | YES  |     | NULL    |       |
| c15   | longblob    | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
15 rows in set (0.00 sec)
 
MariaDB [mydb]> select * from t1;
+-------+-------+-------+-------+---------+------------+---------------------+----------+-------------------+-------------+--------+-------------+-------------+-----------+-----------+
| c1    | c2    | c3    | c4    | c5      | c6         | c7                  | c8       | c9                | c10         | c11    | c12         | c13         | c14       | c15       |
+-------+-------+-------+-------+---------+------------+---------------------+----------+-------------------+-------------+--------+-------------+-------------+-----------+-----------+
| 95000 | 88000 | 12.45 | 99.56 | charone | varcharone | 2018-07-08 10:10:10 | tinytext | <---tinyblob----> | a-text-type | a-blob | medium-text | medium-blob | long-text | long-blob |
+-------+-------+-------+-------+---------+------------+---------------------+----------+-------------------+-------------+--------+-------------+-------------+-----------+-----------+
1 row in set (0.07 sec)
 
insert into l_t1 select * from t1;

#0  0x00007febea629c0e in ha_calpont_impl_write_batch_row_ (buf=0x7feb5002eea2 "\t", table=0x7feb50027e60, ci=...)
    at /home/rprakash/mariadb/mariadb-columnstore-server/mariadb-columnstore-engine/dbcon/mysql/ha_calpont_dml.cpp:1638
#1  0x00007febea5fc7ac in ha_calpont_impl_write_row (buf=0x7feb5002ee28 "", table=0x7feb50027e60)
    at /home/rprakash/mariadb/mariadb-columnstore-server/mariadb-columnstore-engine/dbcon/mysql/ha_calpont_impl.cpp:3435
#2  0x00007febea5eab1d in ha_calpont::write_row (this=0x7feb5004ae98, buf=0x7feb5002ee28 "")
    at /home/rprakash/mariadb/mariadb-columnstore-server/mariadb-columnstore-engine/dbcon/mysql/ha_calpont.cpp:499
#3  0x00005610445a84de in handler::ha_write_row (this=0x7feb5004ae98, buf=0x7feb5002ee28 "")
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/handler.cc:5978
#4  0x00005610442f8880 in write_record (thd=0x7feb50000b00, table=0x7feb50027e60, info=0x7feb5004f778)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_insert.cc:1929
#5  0x00005610442fd8ff in select_insert::send_data (this=0x7feb5004f738, values=...)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_insert.cc:3757
#6  0x0000561044392f0f in end_send (join=0x7feb5004f7e0, join_tab=0x7feb500451e0, end_of_records=false)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:20161
#7  0x00005610443909e5 in evaluate_join_record (join=0x7feb5004f7e0, join_tab=0x7feb50044e30, error=0)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:19213
#8  0x00005610443902ef in sub_select (join=0x7feb5004f7e0, join_tab=0x7feb50044e30, end_of_records=false)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:18993
#9  0x000056104438f88b in do_select (join=0x7feb5004f7e0, procedure=0x0)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:18537
#10 0x0000561044369e9d in JOIN::exec_inner (this=0x7feb5004f7e0)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:3816
#11 0x0000561044368bd2 in JOIN::exec (this=0x7feb5004f7e0)
    at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:3403
#12 0x000056104436a6ae in mysql_select (thd=0x7feb50000b00, tables=0x7feb5004f090, wild_num=1, fields=..., conds=0x0, og_num=0,
    order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7feb5004f738, unit=0x7feb50004800,
    select_lex=0x7feb50004f38) at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:4051
#13 0x000056104435e229 in handle_select (thd=0x7feb50000b00, lex=0x7feb50004738, result=0x7feb5004f738,
    setup_tables_done_option=1073741824) at /home/rprakash/mariadb/mariadb-columnstore-server/sql/sql_select.cc:376



 Comments   
Comment by Ravi Prakash (Inactive) [ 2018-08-09 ]

The crash happened in the following lines of code. The value of dataLength was a huge number.

1634                 if (ci.columnTypes[colpos].colDataType == CalpontSystemCatalog::BLOB)
1635                 {
1636                     for (uint32_t i=0; i<dataLength; i++)
1637                     {
1638                         fprintf(ci.filePtr, "%02x", *(uint8_t*)ucharptr);
1639                         ucharptr++;
1640                     }
1641                     fprintf(ci.filePtr, "%c", ci.delimiter);
1642                 }

Comment by Andrew Hutchings (Inactive) [ 2018-08-09 ]

I thought I had fixed this already a long time ago. Clearly not...

Comment by Ravi Prakash (Inactive) [ 2018-08-14 ]

The problem was in handling of MEDIUMBLOB datatype code. The test case is in the bug description.

Comment by Daniel Lee (Inactive) [ 2018-08-15 ]

Build verified: 1.1.6-1 source

/root/columnstore/mariadb-columnstore-server
commit 513775738f72ec990d055a5d47e2511e3c0e34dd
Merge: 3c37210 9236098
Author: Andrew Hutchings <andrew@linuxjedi.co.uk>
Date: Wed Jul 18 09:37:17 2018 +0100

Merge pull request #123 from drrtuy/MCOL-970

MCOL-970 Slow query log now contains original query even in vtable mode

/root/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine
commit 88bdfccea8a0fa77e995641c7ed015692052b605
Merge: 150171b 5df447b
Author: Andrew Hutchings <andrew@linuxjedi.co.uk>
Date: Wed Aug 15 08:38:15 2018 +0100

Merge pull request #538 from mariadb-corporation/MCOL-1635-1.1

Fix MCOL-1635 where an "insert into table select query" crashes the s…

Reproduced the issue in 1.1.5-1 and verified it is no longer an issue in 1.1.6-1

Comment by Ravi Prakash (Inactive) [ 2018-08-15 ]

Logging the Time spent in fixing the bug.
Time spent: 1d

Generated at Thu Feb 08 02:30:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.