Bug #62190 Bogus assertion in btr_cur_optimistic_update() for compressed tables.
Submitted: 17 Aug 2011 11:15 Modified: 19 Aug 2011 1:04
Reporter: Nizameddin Ordulu Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S2 (Serious)
Version:5.1.52 OS:Linux (Centos5)
Assigned to: CPU Architecture:Any

[17 Aug 2011 11:15] Nizameddin Ordulu
Description:
This is yet another wrong assumption made by high-level innodb functions about whether a record insertion to a compressed page would succeed similar to bugs 61208 and 61456. Stack trace:

110817  2:37:47  InnoDB: Assertion failure in thread 1269463360 in file btr/btr0cur.c line 2021
InnoDB: Failing assertion: rec
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html
InnoDB: about forcing recovery.
110817  2:37:47 - 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.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=16777216
read_buffer_size=1048576
max_used_connections=25
max_threads=5000
threads_connected=15
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 15429938 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x2ab95a3d8330
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 = 0x4baa6a80 thread_stack 0x30000
/usr/libexec/mysqld(my_print_stacktrace+0x2e) [0x8c4b1e]
/usr/libexec/mysqld(handle_segfault+0x324) [0x5e6344]
/lib64/libpthread.so.0 [0x3df100de70]
/lib64/libc.so.6(gsignal+0x35) [0x3df0830155]
/lib64/libc.so.6(abort+0x110) [0x3df0831bf0]
/usr/libexec/mysqld [0x81f780]
/usr/libexec/mysqld [0x7e743c]
/usr/libexec/mysqld [0x7e8136]
/usr/libexec/mysqld [0x7d3f91]
/usr/libexec/mysqld [0x787794]
/usr/libexec/mysqld(handler::ha_update_row(unsigned char const*, unsigned char*)+0x65) [0x6df9b5]
/usr/libexec/mysqld(mysql_update(THD*, TABLE_LIST*, List<Item>&, List<Item>&, Item*, unsigned int, st_order*, unsigned long, enum_duplicates, bool)+0xf87) [0x6862d7]
/usr/libexec/mysqld(mysql_execute_command(THD*, unsigned long long*, unsigned long long*, char)+0x1ca8) [0x5f8338]
/usr/libexec/mysqld(mysql_parse(THD*, char*, unsigned int, char const**, unsigned long long*, char)+0x353) [0x5fe683]
/usr/libexec/mysqld(Query_log_event::do_apply_event(Relay_log_info const*, char const*, unsigned int)+0x46b) [0x6b922b]
/usr/libexec/mysqld(apply_event_and_update_pos(Log_event*, THD*, Relay_log_info*)+0x225) [0x720a55]
/usr/libexec/mysqld(handle_slave_sql+0xa1a) [0x7269fa]
/lib64/libpthread.so.0 [0x3df10062f7]
/lib64/libc.so.6(clone+0x6d) [0x3df08d1e3d]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x2ab92c8dac2d is an invalid pointer
thd->thread_id=64793
thd->killed=NOT_KILLED

The line numbers may not match exactly but the assertion is towards the end of btr_cur_optimistic_update() after the call to btr_cur_insert_if_possible(). excerpt:

2018  if (!(flags & BTR_KEEP_SYS_FLAG)) {
2019    row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
2020                roll_ptr);
2021    row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
2022                trx->id);
2023  }
2024
2025  /* There are no externally stored columns in new_entry */
2026  rec = btr_cur_insert_if_possible(cursor, new_entry, 0/*n_ext*/, mtr);
2027  ut_a(rec); /* <- We calculated above the insert would fit <--PROBLEMATIC ASSERT*/
2028
2029  if (page_zip && !dict_index_is_clust(index)
2030      && page_is_leaf(page)) {
2031    /* Update the free bits in the insert buffer. */
2032    ibuf_update_free_bits_zip(block, mtr);
2033  }
2034
2035  /* Restore the old explicit lock state on the record */
2036
2037  lock_rec_restore_from_page_infimum(block, rec, block);
2038
2039  page_cur_move_to_next(page_cursor);
2040
2041  err = DB_SUCCESS;
2042err_exit:
2043  mem_heap_free(heap);
2044  return(err);
2045}

What is a quick way to fix this without fixing the heuristic? Can I safely call btr_cur_pessimistic_update() ? 

How to repeat:
happened on a slave server with compression enabled. 

Suggested fix:
Call btr_cur_pessimistic_update() somehow?
[19 Aug 2011 1:04] Nizameddin Ordulu
It turns out that the server in question did not have the patch for bug 61191(http://bugs.mysql.com/file.php?id=17054), therefore this is a duplicate of that bug. After applying the patch, the server didn't crash.