-
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
Open
rahulmalik87
wants to merge
1
commit into
percona:8.0
Choose a base branch
from
rahulmalik87:ps-8.0-8687
base: 8.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
drop table if exists t1; | ||
CREATE TABLE t1(i serial); | ||
INSERT INTO t1 VALUES(null); | ||
CREATE TABLE t2(i int , j serial); | ||
INSERT INTO t2 VALUES(1, null); | ||
FLUSH TABLES test.t1 FOR EXPORT; | ||
UNLOCK TABLES; | ||
ALTER TABLE test.t1 DISCARD TABLESPACE; | ||
ALTER TABLE test.t1 IMPORT TABLESPACE; | ||
CHECK TABLE test.t1; | ||
Table Op Msg_type Msg_text | ||
test.t1 check status OK | ||
SHOW CREATE TABLE test.t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`i` bigint unsigned NOT NULL AUTO_INCREMENT, | ||
UNIQUE KEY `i` (`i`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | ||
SELECT * FROM test.t1; | ||
i | ||
1 | ||
# Flush the table and put IBD/CFG files aside for later import. | ||
FLUSH TABLE t1 FOR EXPORT; | ||
"copy done" | ||
UNLOCK TABLES; | ||
ALTER TABLE t1 DISCARD TABLESPACE; | ||
ALTER TABLE t1 IMPORT TABLESPACE; | ||
INSERT INTO t1 VALUES(null); | ||
FLUSH TABLE t2 FOR EXPORT; | ||
"copy done" | ||
UNLOCK TABLES; | ||
ALTER TABLE t2 DISCARD TABLESPACE; | ||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
INSERT INTO t2 VALUES(1, null); | ||
# restart | ||
INSERT INTO t1 VALUES(null); | ||
DROP TABLE t1; | ||
INSERT INTO t2 VALUES(3,null); | ||
DROP TABLE t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--disable_warnings | ||
drop table if exists t1; | ||
--enable_warnings | ||
|
||
CREATE TABLE t1(i serial); | ||
INSERT INTO t1 VALUES(null); | ||
|
||
CREATE TABLE t2(i int , j serial); | ||
INSERT INTO t2 VALUES(1, null); | ||
--source suite/innodb/include/import.inc | ||
|
||
--echo # Flush the table and put IBD/CFG files aside for later import. | ||
FLUSH TABLE t1 FOR EXPORT; | ||
|
||
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/t1.ibd_back | ||
--echo "copy done" | ||
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/t1.cfg_back | ||
|
||
UNLOCK TABLES; | ||
|
||
ALTER TABLE t1 DISCARD TABLESPACE; | ||
|
||
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t1.ibd | ||
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t1.cfg | ||
|
||
ALTER TABLE t1 IMPORT TABLESPACE; | ||
|
||
INSERT INTO t1 VALUES(null); | ||
|
||
FLUSH TABLE t2 FOR EXPORT; | ||
|
||
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/t2.ibd_back | ||
--echo "copy done" | ||
--copy_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/t2.cfg_back | ||
|
||
UNLOCK TABLES; | ||
|
||
ALTER TABLE t2 DISCARD TABLESPACE; | ||
|
||
--copy_file $MYSQLD_DATADIR/t2.ibd_back $MYSQLD_DATADIR/test/t2.ibd | ||
--copy_file $MYSQLD_DATADIR/t2.cfg_back $MYSQLD_DATADIR/test/t2.cfg | ||
|
||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
|
||
INSERT INTO t2 VALUES(1, null); | ||
|
||
--source include/restart_mysqld.inc | ||
|
||
INSERT INTO t1 VALUES(null); | ||
DROP TABLE t1; | ||
|
||
INSERT INTO t2 VALUES(3,null); | ||
DROP TABLE t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:53frame #1: 0x0000000102e40c20 mysqld
dict_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:13frame #3: 0x00000001030ae5b0 mysqld
ha_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:16frame #5: 0x00000001011c194c mysqld
open_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:13frame #7: 0x0000000100e18cb8 mysqld
open_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:15frame #9: 0x0000000100e1c9c0 mysqld
open_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:7frame #11: 0x000000010104c644 mysqld
Sql_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:29frame #13: 0x0000000100f89430 mysqld
dispatch_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:7frame #15: 0x0000000100f87428 mysqld
do_command(thd=0x000000014f94ac00) at sql_parse.cc:1497:18 frame #16: 0x00000001012ec21c mysqld
handle_connection(arg=0x00006000031823e0) at connection_handler_per_thread.cc:308:13frame #17: 0x0000000103731a9c mysqld
pfs_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;