Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Failed to insert a null value to the composite primary key. #1374

Closed
3 tasks done
haitaoguan opened this issue Mar 9, 2023 · 1 comment · Fixed by #1377
Closed
3 tasks done

bug: Failed to insert a null value to the composite primary key. #1374

haitaoguan opened this issue Mar 9, 2023 · 1 comment · Fixed by #1377
Assignees
Labels
A-bug Something isn't working

Comments

@haitaoguan
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

mysql> create table ttt(id int,c1 varchar(10),c2 varchar(10),primary key(id,c1));
Query OK, 0 rows affected (0.01 sec)

mysql> show create table ttt\G
*************************** 1. row ***************************
       Table: ttt
Create Table: CREATE TABLE `ttt` (
  `id` int(11) NOT NULL,
  `c1` varchar(10) NOT NULL,
  `c2` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`,`c1`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

mysql> insert into ttt values(1,'xxx','xxx');
Query OK, 1 row affected (0.00 sec)

mysql> insert into ttt values(1,'','xxx');
ERROR 1030 (HY000): Got error 1 from storage engine

###tianmu.log
[2023-03-09 16:37:41.615755] [32270] [WARN] [exception.cpp:42] MSG: Exception: assert failed on new_data != nullptr at rdb_utils.h:224, msg: [new_data is nullptr].

STACK TRACE BEGIN
        /opt/stonedb57/install//bin/mysqld(Tianmu::common::AssertException::AssertException(char const*, char const*, int, std::string const&)+0x317) [0x1788c47]
        /opt/stonedb57/install//bin/mysqld() [0x99e5ce]
        /opt/stonedb57/install//bin/mysqld(Tianmu::index::RdbKey::pack_key(Tianmu::index::StringWriter&, std::vector<std::string, std::allocator<std::string> >&, Tianmu::index::StringWriter&)+0x155) [0x16ea005]
        /opt/stonedb57/install//bin/mysqld(Tianmu::index::TianmuTableIndex::InsertIndex(Tianmu::core::Transaction*, std::vector<std::string, std::allocator<std::string> >&, unsigned long)+0x51) [0x16f0dc1]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::TianmuTable::InsertIndexForDelta(TABLE*, unsigned long)+0x317) [0x1662197]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::Engine::InsertToDelta(std::string const&, std::shared_ptr<Tianmu::core::TableShare>&, TABLE*)+0x7e) [0x15c2c5e]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::Engine::InsertRow(std::string const&, Tianmu::core::Transaction*, TABLE*, std::shared_ptr<Tianmu::core::TableShare>&)+0x140) [0x15c2f40]
        /opt/stonedb57/install//bin/mysqld(Tianmu::DBHandler::ha_tianmu::write_row(unsigned char*)+0x8c) [0x167c7ec]
        /opt/stonedb57/install//bin/mysqld(handler::ha_write_row(unsigned char*)+0x178) [0xa848f8]
        /opt/stonedb57/install//bin/mysqld(write_record(THD*, TABLE*, COPY_INFO*, COPY_INFO*)+0x60d) [0x1133ecd]
        /opt/stonedb57/install//bin/mysqld(Sql_cmd_insert::mysql_insert(THD*, TABLE_LIST*)+0x835) [0x1134e75]
        /opt/stonedb57/install//bin/mysqld(Sql_cmd_insert::execute(THD*)+0xd2) [0x1135812]
        /opt/stonedb57/install//bin/mysqld(mysql_execute_command(THD*, bool)+0xb1b) [0xfc281b]
        /opt/stonedb57/install//bin/mysqld(mysql_parse(THD*, Parser_state*)+0x425) [0xfc8a85]
        /opt/stonedb57/install//bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x1599) [0xfca089]
        /opt/stonedb57/install//bin/mysqld(do_command(THD*)+0x207) [0xfcada7]
        /opt/stonedb57/install//bin/mysqld(handle_connection+0x2b8) [0x10833d8]
        /opt/stonedb57/install//bin/mysqld(pfs_spawn_thread+0x164) [0x1557b64]
        /lib64/libpthread.so.0(+0x7ea5) [0x7fed489daea5]
        /lib64/libc.so.6(clone+0x6d) [0x7fed466afb0d]
STACK TRACE END

[2023-03-09 16:37:41.615868] [32270] [ERROR] [engine.cpp:1732] MSG: delayed inserting failed. assert failed on new_data != nullptr at rdb_utils.h:224, msg: [new_data is nullptr]
STACK TRACE BEGIN
        /opt/stonedb57/install//bin/mysqld(Tianmu::common::AssertException::AssertException(char const*, char const*, int, std::string const&)+0x317) [0x1788c47]
        /opt/stonedb57/install//bin/mysqld() [0x99e5ce]
        /opt/stonedb57/install//bin/mysqld(Tianmu::index::RdbKey::pack_key(Tianmu::index::StringWriter&, std::vector<std::string, std::allocator<std::string> >&, Tianmu::index::StringWriter&)+0x155) [0x16ea005]
        /opt/stonedb57/install//bin/mysqld(Tianmu::index::TianmuTableIndex::InsertIndex(Tianmu::core::Transaction*, std::vector<std::string, std::allocator<std::string> >&, unsigned long)+0x51) [0x16f0dc1]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::TianmuTable::InsertIndexForDelta(TABLE*, unsigned long)+0x317) [0x1662197]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::Engine::InsertToDelta(std::string const&, std::shared_ptr<Tianmu::core::TableShare>&, TABLE*)+0x7e) [0x15c2c5e]
        /opt/stonedb57/install//bin/mysqld(Tianmu::core::Engine::InsertRow(std::string const&, Tianmu::core::Transaction*, TABLE*, std::shared_ptr<Tianmu::core::TableShare>&)+0x140) [0x15c2f40]
        /opt/stonedb57/install//bin/mysqld(Tianmu::DBHandler::ha_tianmu::write_row(unsigned char*)+0x8c) [0x167c7ec]
        /opt/stonedb57/install//bin/mysqld(handler::ha_write_row(unsigned char*)+0x178) [0xa848f8]
        /opt/stonedb57/install//bin/mysqld(write_record(THD*, TABLE*, COPY_INFO*, COPY_INFO*)+0x60d) [0x1133ecd]
        /opt/stonedb57/install//bin/mysqld(Sql_cmd_insert::mysql_insert(THD*, TABLE_LIST*)+0x835) [0x1134e75]
        /opt/stonedb57/install//bin/mysqld(Sql_cmd_insert::execute(THD*)+0xd2) [0x1135812]
        /opt/stonedb57/install//bin/mysqld(mysql_execute_command(THD*, bool)+0xb1b) [0xfc281b]
        /opt/stonedb57/install//bin/mysqld(mysql_parse(THD*, Parser_state*)+0x425) [0xfc8a85]
        /opt/stonedb57/install//bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x1599) [0xfca089]
        /opt/stonedb57/install//bin/mysqld(do_command(THD*)+0x207) [0xfcada7]
        /opt/stonedb57/install//bin/mysqld(handle_connection+0x2b8) [0x10833d8]
        /opt/stonedb57/install//bin/mysqld(pfs_spawn_thread+0x164) [0x1557b64]
        /lib64/libpthread.so.0(+0x7ea5) [0x7fed489daea5]
        /lib64/libc.so.6(clone+0x6d) [0x7fed466afb0d]
STACK TRACE END

[2023-03-09 16:37:41.615906] [32270] [ERROR] [engine.cpp:930] MSG: Roll back query 'insert into ttt values(1,'','xxx')'
[2023-03-09 16:37:41.615920] [32270] [INFO] [transaction.cpp:90] MSG: rollback transaction 6409619b00002759.
[2023-03-09 16:37:41.615929] [32270] [INFO] [tianmu_table.cpp:702] MSG: roll back table db../db/ttt.tianmu

Expected behavior

No response

How To Reproduce

No response

Environment

./mysqld Ver 5.7.36-StoneDB-v1.0.3 for Linux on x86_64 (build-)
build information as follow:
Repository address: https://github.com/stoneatom/stonedb.git:HEAD
Branch name: HEAD
Last commit ID: e8f0794
Last commit time: Date: Wed Mar 8 19:10:15 2023 +0800
Build time: Date: Thu Mar 9 03:27:59 UTC 2023

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

  • Yes, I will!
@haitaoguan haitaoguan added the A-bug Something isn't working label Mar 9, 2023
@haitaoguan haitaoguan changed the title bug: The insert will failed,when you insert a null to the combinate primary key. bug: Failed to insert a null value to the composite primary key. Mar 9, 2023
@wisehead wisehead added this to the stonedb_5.7_v1.0.3 milestone Mar 9, 2023
@haitaoguan
Copy link
Collaborator Author

version 1.0.2
mysql> create table ttt(id int,c1 varchar(10),c2 int,primary key(id,c1));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into ttt values(1,'',1);
Query OK, 1 row affected (0.01 sec)

mysql> select * from ttt;
Empty set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants