[MDEV-17216] Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning Created: 2018-09-17  Updated: 2018-10-09  Resolved: 2018-10-09

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.4
Fix Version/s: 10.4.0

Type: Bug Priority: Critical
Reporter: Alice Sherepa Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: affects-tests

Issue Links:
Relates
relates to MDEV-8894 Inserting fractional seconds into My... Closed
relates to MDEV-17219 Assertion `!t->fraction_remainder(dec... Closed

 Description   

set sql_mode='';
 
CREATE TABLE t1 (i1 date );
CREATE TABLE t2 (i2 int unsigned );
INSERT INTO t2 VALUES (0);
insert into t1 select * from t2;

  10.4 4437b5bffbfcb71c7e39
Thread 1 (Thread 0x7fcc327b6700 (LWP 8754)):
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
#1  0x00005645c8243d18 in my_write_core (sig=6) at /10.4/mysys/stacktrace.c:481
#2  0x00005645c7a9d147 in handle_fatal_signal (sig=6) at /10.4/sql/signal_handler.cc:305
#3  <signal handler called>
#4  0x00007fcc3e306428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#5  0x00007fcc3e30802a in __GI_abort () at abort.c:89
#6  0x00007fcc3e2febd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x5645c846a038 "!dt->fraction_remainder(decimals())", file=file@entry=0x5645c84699e8 "/10.4/sql/field.cc", line=line@entry=5561, function=function@entry=0x5645c846cea0 <Field_temporal_with_date::store_TIME_with_warning(Datetime const*, ErrConv const*, int)::__PRETTY_FUNCTION__> "int Field_temporal_with_date::store_TIME_with_warning(const Datetime*, const ErrConv*, int)") at assert.c:92
#7  0x00007fcc3e2fec82 in __GI___assert_fail (assertion=0x5645c846a038 "!dt->fraction_remainder(decimals())", file=0x5645c84699e8 "/10.4/sql/field.cc", line=5561, function=0x5645c846cea0 <Field_temporal_with_date::store_TIME_with_warning(Datetime const*, ErrConv const*, int)::__PRETTY_FUNCTION__> "int Field_temporal_with_date::store_TIME_with_warning(const Datetime*, const ErrConv*, int)") at assert.c:101
#8  0x00005645c7a7689a in Field_temporal_with_date::store_TIME_with_warning (this=0x7fcbe4135788, dt=0x7fcc327b42a0, str=0x7fcc327b42d0, was_cut=0) at /10.4/sql/field.cc:5561
#9  0x00005645c7a76c59 in Field_temporal_with_date::store (this=0x7fcbe4135788, nr=0, unsigned_val=true) at /10.4/sql/field.cc:5592
#10 0x00005645c7a8c99c in Field_num::save_in_field (this=0x7fcbe412e3a8, to=0x7fcbe4135788) at /10.4/sql/field.h:1763
#11 0x00005645c7a8b7e6 in Field::store_field (this=0x7fcbe4135788, from=0x7fcbe412e3a8) at /10.4/sql/field.h:767
#12 0x00005645c7a95139 in field_conv_incompatible (to=0x7fcbe4135788, from=0x7fcbe412e3a8) at /10.4/sql/field_conv.cc:836
#13 0x00005645c7a95195 in field_conv (to=0x7fcbe4135788, from=0x7fcbe412e3a8) at /10.4/sql/field_conv.cc:849
#14 0x00005645c7ac80fe in save_field_in_field (from=0x7fcbe412e3a8, null_value=0x7fcbe4017076, to=0x7fcbe4135788, no_conversions=false) at /10.4/sql/item.cc:6445
#15 0x00005645c7ac8340 in Item_field::save_in_field (this=0x7fcbe4017000, to=0x7fcbe4135788, no_conversions=false) at /10.4/sql/item.cc:6496
#16 0x00005645c7723116 in fill_record (thd=0x7fcbe4000b00, table=0x7fcbe40abc60, ptr=0x7fcbe4135780, values=..., ignore_errors=true, use_value=false) at /10.4/sql/sql_base.cc:8490
#17 0x00005645c772332d in fill_record_n_invoke_before_triggers (thd=0x7fcbe4000b00, table=0x7fcbe40abc60, ptr=0x7fcbe4135778, values=..., ignore_errors=true, event=TRG_EVENT_INSERT) at /10.4/sql/sql_base.cc:8543
#18 0x00005645c776e046 in select_insert::store_values (this=0x7fcbe40169e0, values=...) at /10.4/sql/sql_insert.cc:3889
#19 0x00005645c776dccd in select_insert::send_data (this=0x7fcbe40169e0, values=...) at /10.4/sql/sql_insert.cc:3820
#20 0x00005645c781fe46 in end_send (join=0x7fcbe4016a90, join_tab=0x0, end_of_records=false) at /10.4/sql/sql_select.cc:20448
#21 0x00005645c781c1ae in do_select (join=0x7fcbe4016a90, procedure=0x0) at /10.4/sql/sql_select.cc:18765
#22 0x00005645c77f5629 in JOIN::exec_inner (this=0x7fcbe4016a90) at /10.4/sql/sql_select.cc:4089
#23 0x00005645c77f4a9c in JOIN::exec (this=0x7fcbe4016a90) at /10.4/sql/sql_select.cc:3883
#24 0x00005645c77f5d22 in mysql_select (thd=0x7fcbe4000b00, tables=0x7fcbe4015b58, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7fcbe40169e0, unit=0x7fcbe40049b0, select_lex=0x7fcbe40155d0) at /10.4/sql/sql_select.cc:4288
#25 0x00005645c77e768c in handle_select (thd=0x7fcbe4000b00, lex=0x7fcbe40048e8, result=0x7fcbe40169e0, setup_tables_done_option=1073741824) at /10.4/sql/sql_select.cc:382
#26 0x00005645c77ab80f in mysql_execute_command (thd=0x7fcbe4000b00) at /10.4/sql/sql_parse.cc:4837
#27 0x00005645c77b5e85 in mysql_parse (thd=0x7fcbe4000b00, rawbuf=0x7fcbe4014e98 "insert into t1 select * from t2", length=31, parser_state=0x7fcc327b5470, is_com_multi=false, is_next_command=false) at /10.4/sql/sql_parse.cc:8085
#28 0x00005645c77a2f50 in dispatch_command (command=COM_QUERY, thd=0x7fcbe4000b00, packet=0x7fcbe41791d1 "insert into t1 select * from t2", packet_length=31, is_com_multi=false, is_next_command=false) at /10.4/sql/sql_parse.cc:1850
#29 0x00005645c77a196d in do_command (thd=0x7fcbe4000b00) at /10.4/sql/sql_parse.cc:1395
#30 0x00005645c790867f in do_handle_one_connection (connect=0x5645c9ff6bf0) at /10.4/sql/sql_connect.cc:1402
#31 0x00005645c79083d0 in handle_one_connection (arg=0x5645c9ff6bf0) at /10.4/sql/sql_connect.cc:1308
#32 0x00005645c81d422a in pfs_spawn_thread (arg=0x5645c9ffdbd0) at /10.4/storage/perfschema/pfs.cc:1862
#33 0x00007fcc3ef436ba in start_thread (arg=0x7fcc327b6700) at pthread_create.c:333
#34 0x00007fcc3e3d841d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109



 Comments   
Comment by Alice Sherepa [ 2018-09-28 ]

not reproducible after

 
commit 50003a9508f53cbaf6ad46ad071ff48f830ad389
Author: Alexander Barkov <bar@mariadb.com>
Date:   Sat Sep 22 18:33:07 2018 +0400
 
    MDEV-17274 Split Field_temporal_with_date::store*() for Field_date_common and Field_datetime

Comment by Elena Stepanova [ 2018-10-02 ]

I'm still getting similar assertion failures on 10.4 55dd0776566000c5ea12e177df0c784b500ab7c1:

CREATE TABLE t1 (b BIT(20));
CREATE TABLE t2 (t TIMESTAMP);
INSERT IGNORE INTO t1 VALUES (b'000001001100000');
INSERT INTO t2 SELECT * FROM t1;
 
# Cleanup
DROP TABLE t1, t2;

mysqld: /data/src/10.4/sql/field.cc:5064: int Field_timestamp::store_TIME_with_warning(THD*, const Datetime*, const ErrConv*, int): Assertion `!dt->fraction_remainder(decimals())' failed.
181002 21:31:02 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f8aa0784ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000563cc8595757 in Field_timestamp::store_TIME_with_warning (this=0x7f8a88122628, thd=0x7f8a88000b00, dt=0x7f8a9a92a420, str=0x7f8a9a92a450, was_cut=16) at /data/src/10.4/sql/field.cc:5064
#9  0x0000563cc8595cea in Field_timestamp::store (this=0x7f8a88122628, nr=608, unsigned_val=true) at /data/src/10.4/sql/field.cc:5121
#10 0x0000563cc85b26a0 in Field_bit::save_in_field (this=0x7f8a88139428, to=0x7f8a88122628) at /data/src/10.4/sql/field.h:4242
#11 0x0000563cc85ad07a in Field::store_field (this=0x7f8a88122628, from=0x7f8a88139428) at /data/src/10.4/sql/field.h:767
#12 0x0000563cc85b6a3a in field_conv_incompatible (to=0x7f8a88122628, from=0x7f8a88139428) at /data/src/10.4/sql/field_conv.cc:836
#13 0x0000563cc85b6a96 in field_conv (to=0x7f8a88122628, from=0x7f8a88139428) at /data/src/10.4/sql/field_conv.cc:849
#14 0x0000563cc85e9dfb in save_field_in_field (from=0x7f8a88139428, null_value=0x7f8a88017076, to=0x7f8a88122628, no_conversions=false) at /data/src/10.4/sql/item.cc:6447
#15 0x0000563cc85ea03c in Item_field::save_in_field (this=0x7f8a88017000, to=0x7f8a88122628, no_conversions=false) at /data/src/10.4/sql/item.cc:6498
#16 0x0000563cc82403c2 in fill_record (thd=0x7f8a88000b00, table=0x7f8a881418a0, ptr=0x7f8a88122620, values=..., ignore_errors=true, use_value=false) at /data/src/10.4/sql/sql_base.cc:8490
#17 0x0000563cc8240615 in fill_record_n_invoke_before_triggers (thd=0x7f8a88000b00, table=0x7f8a881418a0, ptr=0x7f8a88122618, values=..., ignore_errors=true, event=TRG_EVENT_INSERT) at /data/src/10.4/sql/sql_base.cc:8543
#18 0x0000563cc828b914 in select_insert::store_values (this=0x7f8a880169e0, values=...) at /data/src/10.4/sql/sql_insert.cc:3889
#19 0x0000563cc828b599 in select_insert::send_data (this=0x7f8a880169e0, values=...) at /data/src/10.4/sql/sql_insert.cc:3820
#20 0x0000563cc833e054 in end_send (join=0x7f8a88016a90, join_tab=0x0, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20453
#21 0x0000563cc833a3d9 in do_select (join=0x7f8a88016a90, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:18770
#22 0x0000563cc83133b7 in JOIN::exec_inner (this=0x7f8a88016a90) at /data/src/10.4/sql/sql_select.cc:4089
#23 0x0000563cc8312828 in JOIN::exec (this=0x7f8a88016a90) at /data/src/10.4/sql/sql_select.cc:3883
#24 0x0000563cc8313ab7 in mysql_select (thd=0x7f8a88000b00, tables=0x7f8a88015b58, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7f8a880169e0, unit=0x7f8a880049b0, select_lex=0x7f8a880155d0) at /data/src/10.4/sql/sql_select.cc:4288
#25 0x0000563cc83053a6 in handle_select (thd=0x7f8a88000b00, lex=0x7f8a880048e8, result=0x7f8a880169e0, setup_tables_done_option=1073741824) at /data/src/10.4/sql/sql_select.cc:382
#26 0x0000563cc82c9579 in mysql_execute_command (thd=0x7f8a88000b00) at /data/src/10.4/sql/sql_parse.cc:4837
#27 0x0000563cc82d3905 in mysql_parse (thd=0x7f8a88000b00, rawbuf=0x7f8a88014e98 "INSERT INTO t2 SELECT * FROM t1", length=31, parser_state=0x7f8a9a92b5f0, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8085
#28 0x0000563cc82c0d00 in dispatch_command (command=COM_QUERY, thd=0x7f8a88000b00, packet=0x7f8a8811d4d1 "INSERT INTO t2 SELECT * FROM t1", packet_length=31, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1850
#29 0x0000563cc82bf724 in do_command (thd=0x7f8a88000b00) at /data/src/10.4/sql/sql_parse.cc:1395
#30 0x0000563cc84280a5 in do_handle_one_connection (connect=0x563cca8eb750) at /data/src/10.4/sql/sql_connect.cc:1402
#31 0x0000563cc8427e29 in handle_one_connection (arg=0x563cca8eb750) at /data/src/10.4/sql/sql_connect.cc:1308
#32 0x0000563cc88c9f4d in pfs_spawn_thread (arg=0x563cca980fb0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#33 0x00007f8aa245b494 in start_thread (arg=0x7f8a9a92c700) at pthread_create.c:333
#34 0x00007f8aa084193f in clone () from /lib/x86_64-linux-gnu/libc.so.6

CREATE TABLE t1 (b BIT(20));
CREATE TABLE t2 (t DATETIME);
INSERT IGNORE INTO t1 VALUES (b'000001001100000');
INSERT INTO t2 SELECT * FROM t1;
 
# Cleanup
DROP TABLE t1, t2;

mysqld: /data/src/10.4/sql/field.cc:5550: int Field_datetime::store_TIME_with_warning(const Datetime*, const ErrConv*, int): Assertion `!dt->fraction_remainder(decimals())' failed.
181002 21:32:38 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f4b4c694ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055e419bafa01 in Field_datetime::store_TIME_with_warning (this=0x7f4b341223b8, dt=0x7f4b4683a420, str=0x7f4b4683a450, was_cut=16) at /data/src/10.4/sql/field.cc:5550
#9  0x000055e419bafd6a in Field_datetime::store (this=0x7f4b341223b8, nr=608, unsigned_val=true) at /data/src/10.4/sql/field.cc:5580
#10 0x000055e419bca6a0 in Field_bit::save_in_field (this=0x7f4b34139428, to=0x7f4b341223b8) at /data/src/10.4/sql/field.h:4242
#11 0x000055e419bc507a in Field::store_field (this=0x7f4b341223b8, from=0x7f4b34139428) at /data/src/10.4/sql/field.h:767
#12 0x000055e419bcea3a in field_conv_incompatible (to=0x7f4b341223b8, from=0x7f4b34139428) at /data/src/10.4/sql/field_conv.cc:836
#13 0x000055e419bcea96 in field_conv (to=0x7f4b341223b8, from=0x7f4b34139428) at /data/src/10.4/sql/field_conv.cc:849
#14 0x000055e419c01dfb in save_field_in_field (from=0x7f4b34139428, null_value=0x7f4b34017076, to=0x7f4b341223b8, no_conversions=false) at /data/src/10.4/sql/item.cc:6447
#15 0x000055e419c0203c in Item_field::save_in_field (this=0x7f4b34017000, to=0x7f4b341223b8, no_conversions=false) at /data/src/10.4/sql/item.cc:6498
#16 0x000055e4198583c2 in fill_record (thd=0x7f4b34000b00, table=0x7f4b341419c0, ptr=0x7f4b341223b0, values=..., ignore_errors=true, use_value=false) at /data/src/10.4/sql/sql_base.cc:8490
#17 0x000055e419858615 in fill_record_n_invoke_before_triggers (thd=0x7f4b34000b00, table=0x7f4b341419c0, ptr=0x7f4b341223a8, values=..., ignore_errors=true, event=TRG_EVENT_INSERT) at /data/src/10.4/sql/sql_base.cc:8543
#18 0x000055e4198a3914 in select_insert::store_values (this=0x7f4b340169e0, values=...) at /data/src/10.4/sql/sql_insert.cc:3889
#19 0x000055e4198a3599 in select_insert::send_data (this=0x7f4b340169e0, values=...) at /data/src/10.4/sql/sql_insert.cc:3820
#20 0x000055e419956054 in end_send (join=0x7f4b34016a90, join_tab=0x0, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20453
#21 0x000055e4199523d9 in do_select (join=0x7f4b34016a90, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:18770
#22 0x000055e41992b3b7 in JOIN::exec_inner (this=0x7f4b34016a90) at /data/src/10.4/sql/sql_select.cc:4089
#23 0x000055e41992a828 in JOIN::exec (this=0x7f4b34016a90) at /data/src/10.4/sql/sql_select.cc:3883
#24 0x000055e41992bab7 in mysql_select (thd=0x7f4b34000b00, tables=0x7f4b34015b58, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7f4b340169e0, unit=0x7f4b340049b0, select_lex=0x7f4b340155d0) at /data/src/10.4/sql/sql_select.cc:4288
#25 0x000055e41991d3a6 in handle_select (thd=0x7f4b34000b00, lex=0x7f4b340048e8, result=0x7f4b340169e0, setup_tables_done_option=1073741824) at /data/src/10.4/sql/sql_select.cc:382
#26 0x000055e4198e1579 in mysql_execute_command (thd=0x7f4b34000b00) at /data/src/10.4/sql/sql_parse.cc:4837
#27 0x000055e4198eb905 in mysql_parse (thd=0x7f4b34000b00, rawbuf=0x7f4b34014e98 "INSERT INTO t2 SELECT * FROM t1", length=31, parser_state=0x7f4b4683b5f0, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8085
#28 0x000055e4198d8d00 in dispatch_command (command=COM_QUERY, thd=0x7f4b34000b00, packet=0x7f4b3411d261 "INSERT INTO t2 SELECT * FROM t1", packet_length=31, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1850
#29 0x000055e4198d7724 in do_command (thd=0x7f4b34000b00) at /data/src/10.4/sql/sql_parse.cc:1395
#30 0x000055e419a400a5 in do_handle_one_connection (connect=0x55e41c125750) at /data/src/10.4/sql/sql_connect.cc:1402
#31 0x000055e419a3fe29 in handle_one_connection (arg=0x55e41c125750) at /data/src/10.4/sql/sql_connect.cc:1308
#32 0x000055e419ee1f4d in pfs_spawn_thread (arg=0x55e41c1bafb0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#33 0x00007f4b4e36b494 in start_thread (arg=0x7f4b4683c700) at pthread_create.c:333
#34 0x00007f4b4c75193f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Elena Stepanova [ 2018-10-08 ]

Raised to critical because it badly affects tests on 10.4.

Comment by Alexander Barkov [ 2018-10-09 ]

The same crash is repeatable in these scripts:

CREATE OR REPLACE TABLE t1 (a DATETIME);
INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);

CREATE OR REPLACE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);

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