• Brandon Nesterenko's avatar
    MDEV-20215: binlog.show_concurrent_rotate failed in buildbot with wrong result · 46c3e7e3
    Brandon Nesterenko authored
    Problem:
    =======
    There are two issues that are addressed in this patch:
     1) SHOW BINARY LOGS uses caching to store the binary logs that exist
    in the log directory; however, if new events are written to the logs,
    the caching strategy is unaware. This is okay for users, as it is
    okay for SHOW to return slightly old data. The test, however, can
    result in inconsistent data. It runs two connections concurrently,
    where one shows the logs, and the other adds a new file. The output
    of SHOW BINARY LOGS then depends on when the cache is built, with
    respect to the time that the second connection rotates the logs.
     2) There is a race condition between RESET MASTER and SHOW BINARY
    LOGS. More specifically, where they both need the binary log lock to
    begin, SHOW BINARY LOGS only needs the lock to build its cache. If
    RESET MASTER is issued after SHOW BINARY LOGS has built its cache and
    before it has returned the results, the presented data may be
    incorrect.
    
    Solution:
    ========
     1) As it is okay for users to see stale data, to make the test
    consistent, use DEBUG_SYNC to force the race condition (problem 2) to
    make SHOW BINARY LOGS build a cache before RESET MASTER is called.
    Then, use additional logic from the next part of the solution to
    rebuild the cache.
     2) Use an Atomic_counter to keep track of the number of times RESET
    MASTER has been called. If the value of the counter changes after
    building the cache, the cache should be rebuilt and the analysis
    should be restarted.
    
    Reviewed By:
    ============
    Andrei Elkin: <andrei.elkin@mariadb.com>
    46c3e7e3
log.h 42.9 KB