Bug #23769 Debug assertion failure with innodb_locks_unsafe_for_binlog
Submitted: 30 Oct 2006 12:05 Modified: 27 Nov 2006 19:10
Reporter: Heikki Tuuri Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.0 OS:Any (All)
Assigned to: Marko Mäkelä CPU Architecture:Any
Tags: innodb_locks_unsafe_for_binlog

[30 Oct 2006 12:05] Heikki Tuuri
Description:
lock0lock.c in 5.0:

lock_t*
lock_rec_create(
/*============*/
                                /* out: created lock, NULL if out of memory */
        ulint           type_mode,/* in: lock mode and wait flag, type is
                                ignored and replaced by LOCK_REC */
        rec_t*          rec,    /* in: record on page */
        dict_index_t*   index,  /* in: index of record */
        trx_t*          trx)    /* in: transaction */
{
        page_t* page;
        lock_t* lock;
        ulint   page_no;
        ulint   heap_no;
        ulint   space;
        ulint   n_bits;
        ulint   n_bytes;

#ifdef UNIV_SYNC_DEBUG
        ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */

        page = buf_frame_align(rec);
        space = buf_frame_get_space_id(page);
        page_no = buf_frame_get_page_no(page);
        heap_no = rec_get_heap_no(rec, page_is_comp(page));

        ut_ad(!!page_is_comp(page) == index->table->comp);

        /* If rec is the supremum record, then we reset the gap and
        LOCK_REC_NOT_GAP bits, as all locks on the supremum are
        automatically of the gap type */

        if (rec == page_get_supremum_rec(page)) {
                ut_ad(!(type_mode & LOCK_REC_NOT_GAP));

The assertion above fails.

How to repeat:
Compile InnoDB with all UNIV_DEBUG flags on in univ.i. Run make test.

Suggested fix:
The caller should not use the flag LOCK_REC_NOT_GAP when setting a lock on the 'supremum' pseudo-record on an index page.
[31 Oct 2006 12:43] Heikki Tuuri
Marko has an approved patch for 5.0 (the patch is backported from 5.1).
[15 Nov 2006 9:46] Marko Mäkelä
Proposed changelog entry:

The internal SQL interpreter of InnoDB placed an unnecessary lock on the supremum record when innodb_locks_unsafe_for_binlog=1. This caused an assertion failure when InnoDB was built with debugging enabled.
[27 Nov 2006 19:10] Paul DuBois
Thanks, Marko.

Noted in 5.0.30 (not 5.0.29) changelog.