• Marko Mäkelä's avatar
    MDEV-25215 Excessive logging "InnoDB: Cannot close file" · be803f03
    Marko Mäkelä authored
    In commit 45ed9dd9 (MDEV-23855)
    when removing fil_system.LRU we failed to rate-limit the output
    for reporting violations of innodb_open_files or open_files_limit.
    
    If the server is run with a small limit of open files that is
    well below the number of .ibd files that are being accessed by
    the workload, and if at the same time innodb_log_file_size is
    very small so that log checkpoints will occur frequently,
    the process of enforcing the open files limit may be run very often.
    
    fil_space_t::try_to_close(): Display at most one message per call,
    and only if at least 5 seconds have elapsed since the last time a
    message was output.
    
    fil_node_open_file(): Only output a summary message if
    fil_space_t::try_to_close() displayed a message during this run.
    (Note: multiple threads may execute fil_node_open_file() on
    different files at the same time.)
    
    fil_space_t::get(): Do not dereference a null pointer if n & STOPPING.
    This was caught by the test case below.
    
    Unfortunately, it is not possible to create a fully deterministic
    test case (expecting exactly 1 message to be emitted). The following with
    --innodb-open-files=10 --innodb-log-file-size=4m
    would occasionally fail to find the message in the log:
    
    --source include/have_innodb.inc
    --source include/have_partition.inc
    --source include/have_sequence.inc
    
    call mtr.add_suppression("InnoDB: innodb_open_files=10 is exceeded");
    
    CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB
    PARTITION BY key (pk) PARTITIONS 100;
    
    INSERT INTO t1 SELECT * FROM seq_1_to_100;
    --disable_query_log
    let $n=400;
    while ($n)
    {
    BEGIN; DELETE FROM t1; ROLLBACK;
    dec $n;
    }
    --enable_query_log
    
    let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
    let SEARCH_PATTERN= \[Note\] InnoDB: Cannot close file;
    -- source include/search_pattern_in_file.inc
    
    DROP TABLE t1;
    be803f03
fil0fil.h 57.3 KB