[MDEV-17972] Assertion `is_valid_value_slow()' failed in Datetime::Datetime Created: 2018-12-11  Updated: 2018-12-12  Resolved: 2018-12-12

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - Aria, Temporal Types, Versioned Tables
Affects Version/s: 10.4
Fix Version/s: 10.4.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

Note: the initial part of the scenario is MDEV-17968. Possibly we are facing the "garbage in, garbage out" situation here.

--source include/have_partition.inc
 
CREATE TEMPORARY TABLE tmp (i INT) ENGINE=Aria;
CREATE TABLE t1 LIKE tmp;
ALTER TABLE t1 ADD SYSTEM VERSIONING;
INSERT INTO t1 () VALUES (),();
ALTER TABLE t1 PARTITION BY system_time (PARTITION p1 HISTORY, PARTITION pn CURRENT);
ALTER TABLE t1 ADD PARTITION (PARTITION p2 HISTORY);
 
# This is caused by MDEV-17968
--error 0,ER_GET_ERRNO
DELETE FROM t1;
 
DROP TABLE t1;
CREATE TABLE t1 (i INT NOT NULL) ENGINE=Aria ROW_FORMAT DYNAMIC;
ALTER TABLE t1 ADD SYSTEM VERSIONING ;
ALTER TABLE t1 PARTITION BY system_time LIMIT 10 (PARTITION p1 HISTORY, PARTITION p2 HISTORY, PARTITION pn CURRENT);
 
INSERT INTO t1 SELECT * FROM t1 ;
 
# Cleanup
DROP TABLE t1;

10.4 1c53aeff58e

mysqld: /data/src/10.4/sql/sql_type.h:1962: Datetime::Datetime(THD*, Item*, date_mode_t): Assertion `is_valid_value_slow()' failed.
181211 18:43:47 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f4240856ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000558bb696bfbd in Datetime::Datetime (this=0x7f423a9e7820, thd=0x7f4228000b00, item=0x7f42280170f8, fuzzydate=...) at /data/src/10.4/sql/sql_type.h:1962
#9  0x0000558bb696ce1a in Item::val_datetime_packed (this=0x7f42280170f8, thd=0x7f4228000b00) at /data/src/10.4/sql/item.h:1716
#10 0x0000558bb6dcb563 in Arg_comparator::compare_datetime (this=0x7f4228019658) at /data/src/10.4/sql/item_cmpfunc.cc:727
#11 0x0000558bb6de147c in Arg_comparator::compare (this=0x7f4228019658) at /data/src/10.4/sql/item_cmpfunc.h:104
#12 0x0000558bb6dce8d7 in Item_func_eq::val_int (this=0x7f4228019590) at /data/src/10.4/sql/item_cmpfunc.cc:1749
#13 0x0000558bb6aef304 in evaluate_join_record (join=0x7f4228016a40, join_tab=0x7f4228018c40, error=0) at /data/src/10.4/sql/sql_select.cc:19485
#14 0x0000558bb6aeef17 in sub_select (join=0x7f4228016a40, join_tab=0x7f4228018c40, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:19390
#15 0x0000558bb6aee451 in do_select (join=0x7f4228016a40, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:18930
#16 0x0000558bb6ac6eb1 in JOIN::exec_inner (this=0x7f4228016a40) at /data/src/10.4/sql/sql_select.cc:4094
#17 0x0000558bb6ac62f2 in JOIN::exec (this=0x7f4228016a40) at /data/src/10.4/sql/sql_select.cc:3888
#18 0x0000558bb6ac75b1 in mysql_select (thd=0x7f4228000b00, tables=0x7f4228015a68, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7f4228016990, unit=0x7f42280049c0, select_lex=0x7f42280154e0) at /data/src/10.4/sql/sql_select.cc:4293
#19 0x0000558bb6ab8ebd in handle_select (thd=0x7f4228000b00, lex=0x7f42280048f8, result=0x7f4228016990, setup_tables_done_option=1073741824) at /data/src/10.4/sql/sql_select.cc:385
#20 0x0000558bb6a7c9d5 in mysql_execute_command (thd=0x7f4228000b00) at /data/src/10.4/sql/sql_parse.cc:4836
#21 0x0000558bb6a86ef2 in mysql_parse (thd=0x7f4228000b00, rawbuf=0x7f4228014db8 "INSERT INTO t1 SELECT * FROM t1", length=31, parser_state=0x7f423a9e8600, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8103
#22 0x0000558bb6a7411c in dispatch_command (command=COM_QUERY, thd=0x7f4228000b00, packet=0x7f422800b421 "INSERT INTO t1 SELECT * FROM t1 ", packet_length=32, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1850
#23 0x0000558bb6a72b40 in do_command (thd=0x7f4228000b00) at /data/src/10.4/sql/sql_parse.cc:1395
#24 0x0000558bb6bdea2e in do_handle_one_connection (connect=0x558bbab322c0) at /data/src/10.4/sql/sql_connect.cc:1402
#25 0x0000558bb6bde7b2 in handle_one_connection (arg=0x558bbab322c0) at /data/src/10.4/sql/sql_connect.cc:1308
#26 0x0000558bb709c11e in pfs_spawn_thread (arg=0x558bbaa923b0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#27 0x00007f4242312494 in start_thread (arg=0x7f423a9e9700) at pthread_create.c:333
#28 0x00007f424091393f in clone () from /lib/x86_64-linux-gnu/libc.so.6



 Comments   
Comment by Alexander Barkov [ 2018-12-12 ]

The data file gets corrupted in the above example.

The same crash is repeatable with this test, which intentionally writes corrupt data into the data file.

let $MYSQLD_DATADIR= `select @@datadir`;
SET time_zone='+00:00';
CREATE TABLE t1 (a TIMESTAMP(6)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2001-01-01 10:20:30');
FLUSH TABLES;
--eval SELECT HEX(LOAD_FILE('$MYSQLD_DATADIR/test/t1.MYD')) AS MYD
--remove_file $MYSQLD_DATADIR/test/t1.MYD
--disable_query_log
--eval SELECT 0xFF00000000FFFFFF INTO OUTFILE '$MYSQLD_DATADIR/test/t1.MYD' FIELDS TERMINATED BY '' ESCAPED BY '' LINES TERMINATED BY ''
--eval SELECT HEX(LOAD_FILE('$MYSQLD_DATADIR/test/t1.MYD')) AS MYD
--enable_query_log
SELECT a, CAST(a AS DATETIME) FROM t1;
DROP TABLE t1;
SET time_zone=DEFAULT;

Generated at Thu Feb 08 08:40:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.