• unknown's avatar
    Bug#18544 - LOCK TABLES timeout causes MyISAM table corruption · 40c94ac5
    unknown authored
    After a locking error the open table(s) were not fully
    cleaned up for reuse. But they were put into the open table
    cache even before the lock was tried. The next statement
    reused the table(s) with a wrong lock type set up. This
    tricked MyISAM into believing that it don't need to update
    the table statistics. Hence CHECK TABLE reported a mismatch
    of record count and table size.
    
    Fortunately nothing worse has been detected yet. The effect
    of the test case was that the insert worked on a read locked
    table. (!)
    
    I added a new function that clears the lock type from all
    tables that were prepared for a lock. I call this function
    when a lock failes.
    
    No test case. One test would add 50 seconds to the
    test suite. Another test requires file mode modifications.
    I added a test script to the bug report. It contains three
    cases for failing locks. All could reproduce a table
    corruption. All are fixed by this patch.
    
    This bug was not lock timeout specific.
    
    
    sql/lock.cc:
      Bug#18544 - LOCK TABLES timeout causes MyISAM table corruption
      Resetting the lock type in the open table(s) lock data
      after a locking error.
    40c94ac5
lock.cc 34 KB