• Jon Olav Hauglid's avatar
    Fix for bug #48538 "Assertion in thr_lock() on LOAD DATA CONCURRENT · 0bce0c90
    Jon Olav Hauglid authored
                       INFILE".
    
    Attempts to execute an INSERT statement for a MEMORY table which invoked
    a trigger or called a stored function which tried to perform LOW_PRIORITY
    update on the table being inserted into, resulted in debug servers aborting
    due to an assertion failure. On non-debug servers such INSERTs failed with
    "Can't update table t1 in stored function/trigger because it is already used
    by statement which invoked this stored function/trigger" as expected.
    
    The problem was that in the above scenario TL_WRITE_CONCURRENT_INSERT
    is converted to TL_WRITE inside the thr_lock() function since the MEMORY
    engine does not support concurrent inserts. This triggered an assertion
    which assumed that for the same table, one thread always requests locks with
    higher thr_lock_type value first. When TL_WRITE_CONCURRENT_INSERT is
    upgraded to TL_WRITE after the locks have been sorted, this is no longer true.
    In this case, TL_WRITE was requested after acquiring a TL_WRITE_LOW_PRIORITY
    lock on the table, triggering the assert.
    
    This fix solves the problem by adjusting this assert to take this
    scenario into account.
    
    An alternative approach to change handler::store_locks() methods for all engines
    which do not support concurrent inserts in such way that
    TL_WRITE_CONCURRENT_INSERT is upgraded to TL_WRITE there instead, 
    was considered too intrusive.
    
    Commit on behalf of Dmitry Lenev.
    0bce0c90
lock.test 11.4 KB