-
Notifications
You must be signed in to change notification settings - Fork 479
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
PS-8687 Incorrect autoinc in imported tablespace after restart server #5024
base: 8.0
Are you sure you want to change the base?
Conversation
https://jira.percona.com/browse/PS-8687 Problem: If server is restarted after an import of tablespace. It does not show correct autoinc value and throws duplicate error Analysis: Server presist autoinc value only if table->autoinc_field_no is set During import tablespace server sets autoinc_field_no to UNDEF which makes inserts not to presist autoinc in dd_buffer table Fix: Call dict_table_autoinc_set_col_pos after import tablespace to set the autoinc_field_no which makes inserts to presist autoinc inside row_ins_clust_index_entry_low
@@ -15890,6 +15890,8 @@ int ha_innobase::discard_or_import_tablespace(bool discard, | |||
err = row_import_for_mysql(dict_table, table_def, m_prebuilt); | |||
|
|||
if (err == DB_SUCCESS) { | |||
dict_table_autoinc_set_col_pos( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With normal table, after a restart, can you please how the autoin column position is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please get stack trace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* frame #0: 0x0000000102e62388 mysqld
dict_table_autoinc_set_col_pos(table=0x000000012d737e90, pos=0) at dict0dict.ic:1253:53
frame #1: 0x0000000102e40c20 mysqlddict_table_t* dd_open_table_one<dd::Table>(client=0x000000014f068a70, table=0x000000012f11ec20, norm_name="test/t1", dd_table=0x000000012d74ac30, thd=0x000000014f94ac00, fk_list=size=0) at dict0dd.cc:4934:5 frame #2: 0x0000000102e2b42c mysqld
dict_table_t* dd_open_tabledd::Table(client=0x000000014f068a70, table=0x000000012f11ec20, norm_name="test/t1", dd_table=0x000000012d74ac30, thd=0x000000014f94ac00) at dict0dd.cc:5255:13
frame #3: 0x00000001030ae5b0 mysqldha_innobase::open(this=0x000000012f11f630, name="./test/t1", (null)=2, open_flags=2, table_def=0x000000012d74ac30) at ha_innodb.cc:7778:18 frame #4: 0x00000001007cace4 mysqld
handler::ha_open(this=0x000000012f11f630, table_arg=0x000000012f11ec20, name="./test/t1", mode=2, test_if_locked=2, table_def=0x000000012d74ac30) at handler.cc:2892:16
frame #5: 0x00000001011c194c mysqldopen_table_from_share(thd=0x000000014f94ac00, share=0x000000012f183c30, alias="t1", db_stat=39, prgflag=8, ha_open_flags=0, outparam=0x000000012f11ec20, is_create_table=false, table_def_param=0x000000012d74ac30) at table.cc:3257:36 frame #6: 0x0000000100e125fc mysqld
open_table(thd=0x000000014f94ac00, table_list=0x000000014f959718, ot_ctx=0x0000000179eb51f8) at sql_base.cc:3422:13
frame #7: 0x0000000100e18cb8 mysqldopen_and_process_table(thd=0x000000014f94ac00, lex=0x000000014f938c00, tables=0x000000014f959718, counter=0x000000014f938c58, prelocking_strategy=0x0000000179eb5318, has_prelocking_list=false, ot_ctx=0x0000000179eb51f8) at sql_base.cc:5122:15 frame #8: 0x0000000100e17938 mysqld
open_tables(thd=0x000000014f94ac00, start=0x0000000179eb5328, counter=0x000000014f938c58, flags=0, prelocking_strategy=0x0000000179eb5318) at sql_base.cc:5943:15
frame #9: 0x0000000100e1c9c0 mysqldopen_tables_for_query(thd=0x000000014f94ac00, tables=0x000000014f959718, flags=0) at sql_base.cc:6825:7 frame #10: 0x000000010104b3e0 mysqld
Sql_cmd_dml::prepare(this=0x000000014f959da0, thd=0x000000014f94ac00) at sql_select.cc:360:7
frame #11: 0x000000010104c644 mysqldSql_cmd_dml::execute(this=0x000000014f959da0, thd=0x000000014f94ac00) at sql_select.cc:534:9 frame #12: 0x0000000100f8dc3c mysqld
mysql_execute_command(thd=0x000000014f94ac00, first_level=true) at sql_parse.cc:3815:29
frame #13: 0x0000000100f89430 mysqlddispatch_sql_command(thd=0x000000014f94ac00, parser_state=0x0000000179eb9678, update_userstat=false) at sql_parse.cc:5576:19 frame #14: 0x0000000100f84cf0 mysqld
dispatch_command(thd=0x000000014f94ac00, com_data=0x0000000179ebae10, command=COM_QUERY) at sql_parse.cc:2125:7
frame #15: 0x0000000100f87428 mysqlddo_command(thd=0x000000014f94ac00) at sql_parse.cc:1497:18 frame #16: 0x00000001012ec21c mysqld
handle_connection(arg=0x00006000031823e0) at connection_handler_per_thread.cc:308:13
frame #17: 0x0000000103731a9c mysqldpfs_spawn_thread(arg=0x000000014f0687c0) at pfs.cc:2987:3 frame #18: 0x000000018cec606c libsystem_pthread.dylib
_pthread_start + 148`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rahulmalik87 before the import, the table would have been opened and the autoin col pos is set. Do we destroy the opened table object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in another way, the question is, why it is unset at the time of import? Before import, table open would have set it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of import we explicit set autoinc col pos to UNDEF inside row0import.cc
/* This should be set later in handler level, where we know the autoinc counter field index */ table->autoinc_field_no = ULINT_UNDEFINED;
https://jira.percona.com/browse/PS-8687
Problem:
If server is restarted after an import of tablespace. It does not show correct autoinc value and throws duplicate error
Analysis:
Server presist autoinc value only if table->autoinc_field_no is set During import tablespace server sets autoinc_field_no to UNDEF which makes inserts not to presist autoinc in dd_buffer table
Fix:
Call dict_table_autoinc_set_col_pos after import tablespace to set the autoinc_field_no which makes inserts to presist autoinc inside row_ins_clust_index_entry_low