• Jon Olav Hauglid's avatar
    Bug #49891 View DDL breaks REPEATABLE READ · 349b34b3
    Jon Olav Hauglid authored
    The problem was that if a query accessing a view was blocked due to
    conflicting locks on tables in the view definition, it would be possible
    for a different connection to alter the view definition before the view
    query completed. When the view query later resumed, it used the old view
    definition. This meant that if the view query was later repeated inside
    the same transaction, the two executions of the query would give different
    results, thus breaking repeatable read. (The first query used the old
    view definition, the second used the new view definition).
    
    This bug is no longer repeatable with the recent changes to the metadata
    locking subsystem (revno: 3040). The view query will no longer back-off
    and release the lock on the view definiton. Instead it will wait for
    the conflicting lock(s) to go away while keeping the view definition lock.
    This means that it is no longer possible for a concurrent connection to
    alter the view definition. Instead, any such attempt will be blocked.
    
    In the case from the bug report where the same view query was executed
    twice inside the same transaction, any ALTER VIEW from other connections
    will now be blocked until the transaction has completed (or aborted).
    The view queries will therefore use the same view definition and we will
    have repeatable read.
    
    Test case added to innodb_mysql_lock.test.
    This patch contains no code changes.
    349b34b3
innodb_mysql_lock.result 3.76 KB