• Alfranio Correia's avatar
    BUG#56343 binlog_cache_use status is bigger than expected · c26c9b80
    Alfranio Correia authored
    The binlog_cache_use is incremented twice when changes to a transactional table
    are committed, i.e. TC_LOG_BINLOG::log_xid calls is called. The problem happens
    because log_xid calls both binlog_flush_stmt_cache and binlog_flush_trx_cache
    without checking if such caches are empty thus unintentionally increasing the
    binlog_cache_use value twice.
    
    Although not explicitly mentioned in the bug, the binlog_cache_disk_use presents
    the same problem.
    
    The binlog_cache_use and binlog_cache_disk_use are status variables that are
    incremented when transactional (i.e. trx-cache) or non-transactional (i.e.
    stmt-cache) changes are committed. They are used to compute the ratio between
    the use of disk and memory while gathering updates for a transaction.
    
    The problem reported is fixed by avoiding incrementing the binlog_cache_use
    and binlog_cache_disk_use if a cache is empty. We also have decided to increment
    both variables when a cache is truncated as the cache is used although its
    content is discarded and is not written to the binary log.
    
    In this patch, we take the opportunity to re-organize the code around the
    function binlog_flush_trx_cache and binlog_flush_stmt_cache.
    c26c9b80
log_event.h 122 KB