Commit e284256e authored by unknown's avatar unknown
Browse files

Bug#17733 Flushing logs causes daily server crash

Server crashes if a flush commmand is issued and binlog is closed.
- added check to prevent binlog access when binlog file isn't opened.


sql/sql_parse.cc:
  - removed deprecated environment consistency check.
  - added check to prevent binlog access on closed binlog.
mysql-test/t/flush2-master.opt:
  - Added test case (master options)
mysql-test/t/flush2.test:
  - Added test case
mysql-test/r/flush2.result:
  - Added test case (resultfile)
parent 154c6e06
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
flush logs;
set global expire_logs_days = 3;
show variables like 'log%';
Variable_name	Value
log	ON
log_bin	OFF
log_bin_trust_function_creators	ON
log_error	
log_queries_not_using_indexes	OFF
log_slave_updates	OFF
log_slow_queries	OFF
log_warnings	1
flush logs;
show variables like 'log%';
Variable_name	Value
log	ON
log_bin	OFF
log_bin_trust_function_creators	ON
log_error	
log_queries_not_using_indexes	OFF
log_slave_updates	OFF
log_slow_queries	OFF
log_warnings	1
set global expire_logs_days = 0;
+1 −0
Original line number Diff line number Diff line
--disable-log-bin
+9 −0
Original line number Diff line number Diff line
#
# Bug#17733 Flushing logs causes daily server crash
#
flush logs;
set global expire_logs_days = 3;
show variables like 'log%';
flush logs;
show variables like 'log%';
set global expire_logs_days = 0;
+8 −3
Original line number Diff line number Diff line
@@ -4008,8 +4008,9 @@ mysql_execute_command(THD *thd)
  case SQLCOM_FLUSH:
  {
    bool write_to_binlog;
    if (check_global_access(thd,RELOAD_ACL) || check_db_used(thd, all_tables))
    if (check_global_access(thd,RELOAD_ACL))
      goto error;

    /*
      reload_acl_and_cache() will tell us if we are allowed to write to the
      binlog or not.
@@ -4031,6 +4032,7 @@ mysql_execute_command(THD *thd)
      }
      send_ok(thd);
    } 
    
    break;
  }
  case SQLCOM_KILL:
@@ -6696,7 +6698,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
    tmp_write_to_binlog= 0;
    mysql_log.new_file(1);
    mysql_slow_log.new_file(1);
    if( mysql_bin_log.is_open() )
    {
      mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
    }
#ifdef HAVE_REPLICATION
    pthread_mutex_lock(&LOCK_active_mi);
    rotate_relay_log(active_mi);