zoukankan      html  css  js  c++  java
  • MYSQL_BIN_LOG::purge_logs was called with file '/home/log/mysqlbin.22.log' not listed in the index

    今天接到报警,报警的信息是:

    MYSQL_BIN_LOG::purge_logs was called with file '/home/log/mysql-bin.22.log' not listed in the index

    google一把,查到了mysql的源码:

    View Code
    int MYSQL_BIN_LOG::purge_logs(const char *to_log, 
    bool included,
    bool need_mutex,
    bool need_update_threads,
    ulonglong *decrease_log_space)
    {
    int error= 0;
    bool exit_loop= 0;
    LOG_INFO log_info;
    THD *thd= current_thd;
    DBUG_ENTER("purge_logs");
    DBUG_PRINT("info",("to_log= %s",to_log));

    if (need_mutex)
    pthread_mutex_lock(&LOCK_index);
    if ((error=find_log_pos(&log_info, to_log, 0 /*no mutex*/)))
    {
    sql_print_error("MYSQL_BIN_LOG::purge_logs was called with file %s not "
    "listed in the index.", to_log);
    goto err;
    }

    if ((error= open_purge_index_file(TRUE)))
    {
    sql_print_error("MYSQL_BIN_LOG::purge_logs failed to sync the index file.");
    goto err;
    }

    /*
    File name exists in index file; delete until we find this file
    or a file that is used.
    */
    if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/)))
    goto err;
    while ((strcmp(to_log,log_info.log_file_name) || (exit_loop=included)) &&
    !is_active(log_info.log_file_name) &&
    !log_in_use(log_info.log_file_name))
    {
    if ((error= register_purge_index_entry(log_info.log_file_name)))
    {
    sql_print_error("MYSQL_BIN_LOG::purge_logs failed to copy %s to register file.",
    log_info.log_file_name);
    goto err;
    }

    if (find_next_log(&log_info, 0) || exit_loop)
    break;
    }

    DBUG_EXECUTE_IF("crash_purge_before_update_index", abort(););

    if ((error= sync_purge_index_file()))
    {
    sql_print_error("MSYQL_BIN_LOG::purge_logs failed to flush register file.");
    goto err;
    }

    /* We know how many files to delete. Update index file. */
    if ((error=update_log_index(&log_info, need_update_threads)))
    {
    sql_print_error("MSYQL_BIN_LOG::purge_logs failed to update the index file");
    goto err;
    }

    DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", abort(););

    err:
    /* Read each entry from purge_index_file and delete the file. */
    if (is_inited_purge_index_file() &&
    (error= purge_index_entry(thd, decrease_log_space, FALSE)))
    sql_print_error("MSYQL_BIN_LOG::purge_logs failed to process registered files"
    " that would be purged.");
    close_purge_index_file();

    DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", abort(););

    if (need_mutex)
    pthread_mutex_unlock(&LOCK_index);
    DBUG_RETURN(error);
    }

    详细请看:mysql-binlog 

    log目录下有个index文件,mysql-bin.index,这个文件的目的就是记录所有用过的binlog文件,index随着二进制日志文件的增加,删除,reset master,mysqladmin flush-logs,或者在配置文件里配置expire_logs_days=n而改变,具体使用到的函数是:sync_purge_index_file

    为什么会出现在index文件找不到的情况呢?原因是有个清理二进制日志的脚本,脚本里面遍历/home/log文件夹(这里是没错的),错就错在/home/log里二进制日志文件的命名规则和之前的格式不一样,之前的'/home/log/mysql-bin.22.log' ,之后的日志文件为:mysql-bin.23,而index文件里面只保存了mysql-bin.23样格式的文件名,所以出现上面的问题,解决办法:手动移开mysql-bin.22.log的文件。

  • 相关阅读:
    neo4j 图数据库
    eclipse 当中,两种添加插件的方法 .
    ubuntu16.04如何添加用root用户登录图形界面
    遇到Linux系统安装时窗口过大,按钮点不到,该怎么解决
    hadoop 搭建3节点集群,遇到Live Nodes显示为0时解决办法
    VMware 虚拟机克隆 CentOS 6.5 之后,网络配置问题的解决方案
    scala(13)-----集合(Collection)-------元组
    scala(13)-----集合(Collection)-------Map(映射)
    scala(13)-----集合(Collection)-------Set(集合)
    scala(13)-----集合(Collection)-------列表
  • 原文地址:https://www.cnblogs.com/sunss/p/2320424.html
Copyright © 2011-2022 走看看