stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: debug version,mysqld crashed when processing timestamp data type

Open davidshiz opened this issue 2 years ago • 1 comments
trafficstars

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • [X] I confirm there is no existing issue for this

Describe the problem

CURRENT_TEST: tianmu.type_timestamp
mysqltest: At line 71: query 'SELECT a, DAYNAME(a), DAYOFWEEK(a), DATE_FORMAT(a, '%W %M %Y'),
MONTHNAME(a), DATE(a), YEARWEEK(a), DAYOFYEAR(a), YEAR(a),
a + INTERVAL 1 DAY, TIMESTAMPDIFF(DAY, a, '2020-01-01'),
LAST_DAY(a), TRUNCATE(a, -2), a IN ('2019-01-02 01:02:03', a),
TO_DAYS(a), DAY(a), WEEK(a), WEEKDAY(a), GREATEST(a, '2020-07-01'),
MONTH(a), QUARTER(a), DATE_ADD(a, INTERVAL 1 SECOND)
FROM ctimestamp WHERE a > '2020-01-01' ORDER BY a' failed: 2013: Lost connection to MySQL server during query

The result from queries just before the failure was:
< snip >
1994-01-01 00:00:00
1994-01-01 01:02:03
1994-01-01 01:02:03
1994-01-01 01:02:03
DROP DATABASE IF EXISTS timestamp_test;
CREATE DATABASE timestamp_test;
USE timestamp_test;
CREATE TABLE ctimestamp (a timestamp);
SET time_zone='+0:00';
INSERT INTO ctimestamp VALUES ('2019-01-02 00:02:03'),
('2019-01-02 01:02:03'), ('2019-01-02 10:11:12');
SET time_zone='+1:00';
SELECT a, a BETWEEN '2019-01-02 02:00:00' AND '2019-01-02 13:00:00'
FROM ctimestamp ORDER BY a;
a       a BETWEEN '2019-01-02 02:00:00' AND '2019-01-02 13:00:00'
2019-01-02 01:02:03     0
2019-01-02 02:02:03     1
2019-01-02 11:11:12     1
INSERT INTO ctimestamp VALUES ('2020-01-03 12:12:12'),
('2020-05-06 12:12:12'), ('2020-10-28 12:12:12');
safe_process[89721]: Child process: 89722, exit: 1


Server [mysqld.1 - pid: 87713, winpid: 87713, exit: 256] failed during test run
Server log from this test:
----------SERVER LOG START-----------
mysqld: /stonedb/include/template_utils.h:85: Target down_cast(Source) [with Target = const Item_func_in*; Source = const Item*]: Assertion `__null != dynamic_cast<Target>(arg)' failed.
02:44:07 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=3
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 61094 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f4204000950
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f4c88143640 thread_stack 0x40000
/stonedb57/install/bin/mysqld(my_print_stacktrace+0x35)[0x277990d]
/stonedb57/install/bin/mysqld(handle_fatal_signal+0x3e4)[0x1d5fecf]
/lib64/libpthread.so.0(+0xf630)[0x7f4caeb10630]
/lib64/libc.so.6(gsignal+0x37)[0x7f4cac50b387]
/lib64/libc.so.6(abort+0x148)[0x7f4cac50ca78]
/lib64/libc.so.6(+0x2f1a6)[0x7f4cac5041a6]
/lib64/libc.so.6(+0x2f252)[0x7f4cac504252]
/stonedb57/install/bin/mysqld(_Z9down_castIPK12Item_func_inPK4ItemET_T0_+0x5b)[0x30e3772]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4coreeqERK4ItemS3_+0x499)[0x30e1cd1]
/stonedb57/install/bin/mysqld(_ZNK6Tianmu4core15MysqlExpressioneqERKS1_+0x8e)[0x30e20dc]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core5Query26VirtualColumnAlreadyExistsERKNS0_5TabIDEPNS0_15MysqlExpressionE+0x8d)[0x2d19de1]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core5Query27AddColumnForMysqlExpressionEPNS0_15MysqlExpressionERKNS0_5TabIDEPKcNS_6common12ColOperationEbb+0x83)[0x2d435b9]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core5Query9AddFieldsER4ListI4ItemERKNS0_5TabIDES8_bRibRb+0x944)[0x2d4095a]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core5Query7CompileEPNS0_13CompiledQueryEP13st_select_lexS5_PNS0_5TabIDEbP4ItemPNS_6common8OperatorEbb+0xa89)[0x2d44453]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core6Engine7ExecuteEP3THDP3LEXP12Query_resultP18st_select_lex_unit+0x5c2)[0x2d0a0c6]
/stonedb57/install/bin/mysqld(_ZN6Tianmu4core6Engine12HandleSelectEP3THDP3LEXRP12Query_resultmRiS9_S9_i+0x8da)[0x2d0926c]
/stonedb57/install/bin/mysqld(_ZN6Tianmu9DBHandler18ha_my_tianmu_queryEP3THDP3LEXRP12Query_resultmRiS8_S8_i+0xac)[0x309f553]
/stonedb57/install/bin/mysqld[0x244712e]
/stonedb57/install/bin/mysqld(_Z21mysql_execute_commandP3THDb+0xdfb)[0x24407b0]
/stonedb57/install/bin/mysqld(_Z11mysql_parseP3THDP12Parser_state+0x6ae)[0x244816d]
/stonedb57/install/bin/mysqld(_Z16dispatch_commandP3THDPK8COM_DATA19enum_server_command+0xcc0)[0x243d4f6]
/stonedb57/install/bin/mysqld(_Z10do_commandP3THD+0x4bb)[0x243c340]
/stonedb57/install/bin/mysqld(handle_connection+0x1ec)[0x256e513]
/stonedb57/install/bin/mysqld(pfs_spawn_thread+0x170)[0x2c3d33b]
/lib64/libpthread.so.0(+0x7ea5)[0x7f4caeb08ea5]
/lib64/libc.so.6(clone+0x6d)[0x7f4cac5d3b0d]

Expected behavior

No response

How To Reproduce

No response

Environment

[root@stonedb-test support-files]# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB-v1.0.1.6b369e5 for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 6b369e5
        Last commit time: Date:   Thu Jun 8 19:16:12 2023 +0800
        Build time: Date: Tue Jun 13 08:31:13 UTC 2023

Are you interested in submitting a PR to solve the problem?

  • [ ] Yes, I will!

davidshiz avatar Jun 14 '23 03:06 davidshiz

simplify the sql, as follows

SELECT
    a IN ('2019-01-02 01:02:03', a),
    TO_DAYS(a),
    DAY(a)
FROM
    ctimestamp;

davidshiz avatar Jun 14 '23 03:06 davidshiz