• kroki/tomash@moonlight.intranet's avatar
    Bug#16581: deadlock: server and client both read from connection in · d06001b1
    kroki/tomash@moonlight.intranet authored
               'conc_sys' test
    
    Concurrent execution of SELECT involing at least two INFORMATION_SCHEMA
    tables, DROP DATABASE statement and DROP TABLE statement could have
    resulted in stalled connection for this SELECT statement.
    
    The problem was that for the first query of a join there was a race
    between select from I_S.TABLES and DROP DATABASE, and the error (no
    such database) was prepared to be send to the client, but the join
    processing was continued.  On second query to I_S.COLUMNS there was a
    race with DROP TABLE, but this error (no such table) was downgraded to
    warning, and thd->net.report_error was reset.  And so neither result
    nor error was sent to the client.
    
    The solution is to stop join processing once it is clear we are going
    to report a error, and also to downgrade to warnings file system errors
    like 'no such database' (unless we are in the 'SHOW' command), because
    I_S is designed not to use locks and the query to I_S should not abort
    if something is dropped in the middle.
    
    No test case is provided since this bug is a result of a race, and is
    timing dependant.  But we test that plain SHOW TABLES and SHOW COLUMNS
    give a error if there is no such database or a table respectively.
    d06001b1
show_check.test 13.3 KB