Bug #65429 Assertion failure block->page.space == page_get_space_id(page_align(ptr))
Submitted: 26 May 2012 14:51 Modified: 23 Apr 2015 11:32
Reporter: Elena Stepanova Email Updates:
Status: Won't fix Impact on me:
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.5, 5.6 OS:Any
Assigned to: CPU Architecture:Any

[26 May 2012 14:51] Elena Stepanova
InnoDB: Assertion failure in thread 139724803139328 in file buf0buf.cc line 2258
InnoDB: Failing assertion: block->page.space == page_get_space_id(page_align(ptr))

#4  0x00007f143ee7b3a5 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#5  0x00007f143ee7eb0b in __GI_abort () at abort.c:92
#6  0x0000000000badeda in buf_block_align_instance (buf_pool=0x1a5ddf8, ptr=0x7f143a110000 "") at storage/innobase/buf/buf0buf.cc:2257
#7  0x0000000000badf9a in buf_block_align (ptr=0x7f143a110000 "") at storage/innobase/buf/buf0buf.cc:2289
#8  0x0000000000a8eb9a in mtr_memo_contains_page (mtr=0x7f1437419f20, ptr=0x7f143a110000 "", type=2) at storage/innobase/mtr/mtr0mtr.cc:402
#9  0x0000000000a5a70f in ibuf_bitmap_page_get_bits_low (page=0x7f143a110000 "", page_no=3, zip_size=0, latch_type=2, mtr=0x7f1437419f20, bit=2) at storage/innobase/ibuf/ibuf0ibuf.cc:721
#10 0x0000000000a616eb in ibuf_merge_or_delete_for_page (block=0x7f1439e69460, space=1, page_no=3, zip_size=0, update_ibuf_bitmap=1) at storage/innobase/ibuf/ibuf0ibuf.cc:4328
#11 0x0000000000bb270a in buf_page_io_complete (bpage=0x7f1439e69460) at storage/innobase/buf/buf0buf.cc:4018
#12 0x0000000000bcadca in buf_read_page_low (err=0x7f143741a54c, sync=1, mode=132, space=1, zip_size=0, unzip=0, tablespace_version=4, offset=3) at storage/innobase/buf/buf0rea.cc:168
#13 0x0000000000bcb2e2 in buf_read_page (space=1, zip_size=0, offset=3) at storage/innobase/buf/buf0rea.cc:364
#14 0x0000000000bae6b8 in buf_page_get_gen (space=1, zip_size=0, offset=3, rw_latch=3, guess=0x0, mode=10, file=0xf97738 "storage/innobase/include/btr0pcur.ic", line=520, mtr=0x7f143741aeb0) at storage/innobase/buf/buf0buf.cc:2501
#15 0x0000000000b8e33c in btr_cur_open_at_index_side_func (from_left=1, index=0x1b3e948, latch_mode=1, cursor=0x1cc1488, file=0xf97738 "storage/innobase/include/btr0pcur.ic", line=520, mtr=0x7f143741aeb0) at storage/innobase/btr/btr0cur.cc:912
#16 0x0000000000b0ba77 in btr_pcur_open_at_index_side (from_left=1, index=0x1b3e948, latch_mode=1, pcur=0x1cc1488, do_init=0, mtr=0x7f143741aeb0) at storage/innobase/include/btr0pcur.ic:520
#17 0x0000000000b13620 in row_search_for_mysql (buf=0x1cc4600 "\377", mode=1, prebuilt=0x1cc1418, match_mode=0, direction=0) at storage/innobase/row/row0sel.cc:4194
#18 0x0000000000a2ec21 in ha_innobase::index_read (this=0x1cbf8d0, buf=0x1cc4600 "\377", key_ptr=0x0, key_len=0, find_flag=HA_READ_AFTER_KEY) at storage/innobase/handler/ha_innodb.cc:7217
#19 0x0000000000a2f6be in ha_innobase::index_first (this=0x1cbf8d0, buf=0x1cc4600 "\377") at storage/innobase/handler/ha_innodb.cc:7541
#20 0x0000000000a2f89e in ha_innobase::rnd_next (this=0x1cbf8d0, buf=0x1cc4600 "\377") at storage/innobase/handler/ha_innodb.cc:7638
#21 0x00000000005fad22 in handler::ha_rnd_next (this=0x1cbf8d0, buf=0x1cc4600 "\377") at sql/handler.cc:2506
#22 0x0000000000935a86 in rr_sequential (info=0x1c8d980) at sql/records.cc:479
#23 0x00000000007595e9 in join_init_read_record (tab=0x1c8d8f8) at sql/sql_executor.cc:3178
#24 0x000000000075727a in sub_select (join=0x1c8cae8, join_tab=0x1c8d8f8, end_of_records=false) at sql/sql_executor.cc:2166
#25 0x00000000007566a7 in do_select (join=0x1c8cae8, fields=0x1c7b748, table=0x0, procedure=0x0) at sql/sql_executor.cc:1678
#26 0x0000000000753df1 in JOIN::execute (this=0x1c8cae8, parent=0x0) at sql/sql_executor.cc:770
#27 0x0000000000751972 in JOIN::exec (this=0x1c8cae8) at sql/sql_executor.cc:266
#28 0x00000000007d884e in mysql_select (thd=0x1c78f40, tables=0x1c8c4a0, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1c8cac0, unit=0x1c7afc8, select_lex=0x1c7b628) at sql/sql_select.cc:1066
#29 0x00000000007d6c10 in handle_select (thd=0x1c78f40, lex=0x1c7af18, result=0x1c8cac0, setup_tables_done_option=0) at sql/sql_select.cc:107
#30 0x00000000007a9388 in execute_sqlcom_select (thd=0x1c78f40, all_tables=0x1c8c4a0) at sql/sql_parse.cc:4938
#31 0x00000000007a2241 in mysql_execute_command (thd=0x1c78f40) at sql/sql_parse.cc:2515
#32 0x00000000007ab66f in mysql_parse (thd=0x1c78f40, rawbuf=0x1c8c2b0 "SELECT * FROM t1", length=16, parser_state=0x7f143741d110) at sql/sql_parse.cc:6025
#33 0x000000000079f63d in dispatch_command (command=COM_QUERY, thd=0x1c78f40, packet=0x1c84281 "", packet_length=16) at sql/sql_parse.cc:1275
#34 0x000000000079e895 in do_command (thd=0x1c78f40) at sql/sql_parse.cc:998
#35 0x0000000000747790 in do_handle_one_connection (thd_arg=0x1c78f40) at sql/sql_connect.cc:942
#36 0x00000000007471b5 in handle_one_connection (arg=0x1c78f40) at sql/sql_connect.cc:858
#37 0x0000000000c8bcc0 in pfs_spawn_thread (arg=0x1b0b2f0) at storage/perfschema/pfs.cc:1800
#38 0x00007f143f98eefc in start_thread (arg=0x7f143741e700) at pthread_create.c:304

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (1c8c2b0): SELECT * FROM t1
Connection ID (thread ID): 2

How to repeat:
--source include/have_innodb.inc
SET GLOBAL innodb_file_per_table=1;


--let $datadir = `SELECT @@datadir`
--copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save

--error ER_GET_ERRNO

--move_file $datadir/test/t1.ibd.save $datadir/test/t1.ibd

[26 May 2012 16:12] Valeriy Kravchuk
Thank you for the bug report. Verified with 5.5.26 on Mac OS X using your test case:

120526 19:10:17 [Note] /Users/openxs/dbs/5.5/bin/mysqld: ready for connections.
Version: '5.5.26-debug-log'  socket: '/Users/openxs/dbs/5.5/mysql-test/var/tmp/mysqld.1.sock'  port: 13000  Source distribution
120526 19:10:18  InnoDB: Error:
InnoDB: MySQL is trying to use a table handle but the .ibd file for
InnoDB: table test/t1 does not exist.
InnoDB: Have you deleted the .ibd file from the database directory under
InnoDB: the MySQL datadir, or have you used DISCARD TABLESPACE?
InnoDB: Look from
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
InnoDB: how you can resolve the problem.
120526 19:10:18  InnoDB: Assertion failure in thread 4380418048 in file buf0buf.c line 2080
InnoDB: Failing assertion: block->page.space == page_get_space_id(page_align(ptr))
[25 Jun 2012 1:33] Stewart Smith
I think this should be marked as Not a Bug.

Quoting from manual ( http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/partial.restoring.single.html ): 
If you have a *clean* backup of an .ibd file, you can restore it to the MySQL installation from which it originated as follows:

In this context, a clean.ibd file backup means:

There are no uncommitted modifications by transactions in the .ibd file.

There are no unmerged insert buffer entries in the .ibd file.

Purge has removed all delete-marked index records from the .ibd file.

mysqld has flushed all modified pages of the .ibd file from the buffer pool to the file.

You can make such a clean backup .ibd file with the following method:

Stop all activity from the mysqld server and commit all transactions.

Wait until SHOW INNODB STATUS shows that there are no active transactions in the database, and the main thread status of InnoDB is Waiting for server activity. Then you can make a copy of the .ibd file.

Another method for making a clean copy of an .ibd file is to use ibbackup:

Use ibbackup to back up the InnoDB installation.

Run ibbackup --apply-log to create a consistent version of the backup database.

Start a second (dummy) mysqld server on the backup and let it clean up the .ibd files in the backup. Wait for the cleanup to end.

Shut down the dummy mysqld server.

Take a clean .ibd file from the backup.
[25 Jun 2012 2:35] Elena Stepanova
I agree that the test case does not demonstrate good practice, so it would be totally fine if the import failed. However, I would expect that a non-debug server should be able to do better than abort on an attempt to import a wrongly created ibd backup, as it happens now (especially considering that the first method of taking a backup is error-prone, as on a real-world server something might always happen between running SHOW INNODB STATUS and copying the file, and the second method is cumbersome and rather expensive). 
Nevertheless, if you think it's fine for the server to shutdown in this situation, please feel free to close the report.