mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 19:06:14 +01:00 
			
		
		
		
	 47010ccffa
			
		
	
	
	47010ccffa
	
	
	
		
			
			- Major rewrite of ddl_log.cc and ddl_log.h
  - ddl_log.cc described in the beginning how the recovery works.
  - ddl_log.log has unique signature and is dynamic. It's easy to
    add more information to the header and other ddl blocks while still
    being able to execute old ddl entries.
  - IO_SIZE for ddl blocks is now dynamic. Can be changed without affecting
    recovery of old logs.
  - Code is more modular and is now usable outside of partition handling.
  - Renamed log file to dll_recovery.log and added option --log-ddl-recovery
    to allow one to specify the path & filename.
- Added ddl_log_entry_phase[], number of phases for each DDL action,
  which allowed me to greatly simply set_global_from_ddl_log_entry()
- Changed how strings are stored in log entries, which allows us to
  store much more information in a log entry.
- ddl log is now always created at start and deleted on normal shutdown.
  This simplices things notable.
- Added probes debug_crash_here() and debug_simulate_error() to simply
  crash testing and allow crash after a given number of times a probe
  is executed. See comments in debug_sync.cc and rename_table.test for
  how this can be used.
- Reverting failed table and view renames is done trough the ddl log.
  This ensures that the ddl log is tested also outside of recovery.
- Added helper function 'handler::needs_lower_case_filenames()'
- Extend binary log with Q_XID events. ddl log handling is using this
  to check if a ddl log entry was logged to the binary log (if yes,
  it will be deleted from the log during ddl_log_close_binlogged_events()
- If a DDL entry fails 3 time, disable it. This is to ensure that if
  we have a crash in ddl recovery code the server will not get stuck
  in a forever crash-restart-crash loop.
mysqltest.cc changes:
- --die will now replace $variables with their values
- $error will contain the error of the last failed statement
storage engine changes:
- maria_rename() was changed to be more robust against crashes during
  rename.
		
	
			
		
			
				
	
	
		
			171 lines
		
	
	
	
		
			4.8 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			171 lines
		
	
	
	
		
			4.8 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| #
 | |
| # This tests tries cover most of the recovery cases in
 | |
| # DDL_LOG_RENAME_TABLE_ACTION and do_rename()
 | |
| # This test does not intend to crash the server
 | |
| # It's a complement to main.rename
 | |
| #
 | |
| 
 | |
| create database test2;
 | |
| 
 | |
| --echo #
 | |
| --echo # Testing rename error in different places
 | |
| --echo #
 | |
| 
 | |
| create table t1 (a int);
 | |
| create table t2 (b int);
 | |
| create table t3 (c int);
 | |
| create table t4 (d int);
 | |
| 
 | |
| insert into t1 values(1);
 | |
| insert into t2 values(2);
 | |
| insert into t3 values(3);
 | |
| insert into t4 values(4);
 | |
| 
 | |
| create temporary table tmp1 (a int);
 | |
| create temporary table tmp2 (b int);
 | |
| create temporary table tmp3 (c int);
 | |
| create temporary table tmp4 (d int);
 | |
| 
 | |
| insert into tmp1 values(11);
 | |
| insert into tmp2 values(22);
 | |
| insert into tmp3 values(33);
 | |
| insert into tmp4 values(44);
 | |
| 
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t3 to t4, t1 to t5, t2 to t1, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t3 to t4, t2 to t1, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t3 to t4, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, t3 to t4;
 | |
| 
 | |
| --echo # Try failed rename using two databases
 | |
| --error ER_NO_SUCH_TABLE
 | |
| rename table test.t1 to test2.t5, test.t2 to test.t1, t5 to test.t2;
 | |
| 
 | |
| select t1.a+t2.b+t3.c+t4.d from t1,t2,t3,t4;
 | |
| --error ER_NO_SUCH_TABLE
 | |
| select * from t5;
 | |
| 
 | |
| --echo #
 | |
| --echo # Testing rename error in different places with temporary tables
 | |
| --echo #
 | |
| 
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table tmp3 to tmp4, tmp1 to t5, tmp2 to tmp1, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table tmp1 to t5, tmp3 to tmp4, tmp2 to tmp1, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table tmp1 to t5, tmp2 to tmp1, tmp3 to tmp4, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table tmp1 to t5, tmp2 to tmp1, t5 to tmp1, tmp3 to tmp4;
 | |
| 
 | |
| select tmp1.a+tmp2.b+tmp3.c+tmp4.d from tmp1,tmp2,tmp3,tmp4;
 | |
| --error ER_NO_SUCH_TABLE
 | |
| select * from t5;
 | |
| 
 | |
| --echo #
 | |
| --echo # Testing combinations of rename normal and temporary tables
 | |
| --echo #
 | |
| 
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, tmp3 to tmp4, tmp1 to t5, tmp2 to tmp1, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, tmp1 to t5, tmp3 to tmp4, tmp2 to tmp1, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, tmp1 to t5, tmp2 to tmp1, tmp3 to tmp4, t5 to tmp1;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, tmp1 to t5, tmp2 to tmp1, t5 to tmp1, t3 to t4;
 | |
| 
 | |
| --error ER_NO_SUCH_TABLE
 | |
| rename table t1 to t5, tmp2 to tmp5, t2 to t1, tmp2 to tmp1, t5 to t2, tmp5 to tmp1, t8 to t9;
 | |
| 
 | |
| select t1.a+t2.b+t3.c+t4.d from t1,t2,t3,t4;
 | |
| select tmp1.a+tmp2.b+tmp3.c+tmp4.d from tmp1,tmp2,tmp3,tmp4;
 | |
| 
 | |
| drop table tmp1,tmp2,tmp3,tmp4;
 | |
| 
 | |
| --echo #
 | |
| --echo # Similar tests with triggers
 | |
| --echo #
 | |
| 
 | |
| delimiter |;
 | |
| create trigger t1_trg before insert on t1 for each row
 | |
| begin
 | |
|   if isnull(new.a) then
 | |
|     set new.a:= 10;
 | |
|   end if;
 | |
| end|
 | |
| create trigger t2_trg before insert on t2 for each row
 | |
| begin
 | |
|   if isnull(new.b) then
 | |
|     set new.b:= 100;
 | |
|   end if;
 | |
| end|
 | |
| create trigger t3_trg before insert on t3 for each row
 | |
| begin
 | |
|   if isnull(new.c) then
 | |
|     set new.c:= 1000;
 | |
|   end if;
 | |
| end|
 | |
| 
 | |
| delimiter ;|
 | |
| 
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t3 to t4, t1 to t5, t2 to t1, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t3 to t4, t2 to t1, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t3 to t4, t5 to t2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table t1 to t5, t2 to t1, t5 to t2, t3 to t4;
 | |
| 
 | |
| --echo # Test of move table between databases
 | |
| --error ER_TRG_IN_WRONG_SCHEMA
 | |
| rename table t4 to test2.t5, t2 to t4, test2.t5 to t2, t1 to test2.t6;
 | |
| 
 | |
| --replace_column 6 #
 | |
| show triggers;
 | |
| 
 | |
| select t1.a+t2.b+t3.c+t4.d from t1,t2,t3,t4;
 | |
| insert into t1 values(null);
 | |
| insert into t2 values(null);
 | |
| insert into t3 values(null);
 | |
| select (select sum(t1.a) from t1)+ (select sum(t2.b) from t2) + (select sum(t3.c) from t3)+ (select sum(t4.d) from t4);
 | |
| 
 | |
| drop trigger t1_trg;
 | |
| drop trigger t2_trg;
 | |
| drop trigger t3_trg;
 | |
| 
 | |
| --echo #
 | |
| --echo # Test with views
 | |
| --echo #
 | |
| 
 | |
| create view v1 as select * from t1;
 | |
| create view v2 as select * from t2;
 | |
| create view v3 as select * from t3;
 | |
| create view v4 as select * from t4;
 | |
| 
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table v3 to v4, v1 to t5, v2 to v1, t5 to v2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table v1 to t5, v3 to v4, v2 to v1, t5 to v2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table v1 to t5, v2 to v1, v3 to v4, t5 to v2;
 | |
| --error ER_TABLE_EXISTS_ERROR
 | |
| rename table v1 to t5, v2 to v1, t5 to v2, v3 to v4;
 | |
| 
 | |
| --echo # Try failed rename using two databases
 | |
| --error ER_FORBID_SCHEMA_CHANGE
 | |
| rename table test.v1 to test.v5, test.v2 to test.v1, test.v3 to test2.v2, non_existing_view to another_non_existing_view;
 | |
| 
 | |
| select (select sum(v1.a) from v1)+ (select sum(v2.b) from v2) + (select sum(v3.c) from v3)+ (select sum(v4.d) from v4);
 | |
| 
 | |
| drop view v1,v2,v3,v4;
 | |
| 
 | |
| #
 | |
| # Clean up
 | |
| #
 | |
| drop table t1, t2, t3, t4;
 | |
| drop database test2;
 |