1--source include/have_debug.inc 2--source include/have_debug_sync.inc 3--source include/have_rocksdb.inc 4--source include/count_sessions.inc 5 6--disable_query_log 7call mtr.add_suppression("Cannot mark Column family.*because it is used by an ongoing add index command"); 8--enable_query_log 9 10set @old_debug = @@global.debug; 11 12connect (conn1,localhost,root,,); 13connect (conn2,localhost,root,,); 14 15--connection conn1 16create table t1 ( 17 id1 int(10) unsigned not null default '0', 18 id2 int(10) unsigned not null default '0', 19 primary key (id1) comment 'cf_primary_key' 20 ) engine=rocksdb; 21 22insert into t1 (id1, id2) 23 values(1, 1); 24 25insert into t1 (id1, id2) 26 values(2, 2); 27 28insert into t1 (id1, id2) 29 values(3, 3); 30 31set global rocksdb_force_flush_memtable_now = true; 32 33## test1 ## 34--connection conn1 35create table create_cf ( id int, primary key (id) comment 'cf_secondary_key' ) engine=rocksdb; 36drop table create_cf; 37set @@global.debug = '+d,rocksdb_create_secondary_cf'; 38set @@global.debug = '+d,rocksdb_drop_cf'; 39 40send alter table t1 add index secondary_key (id2) comment 'cf_secondary_key'; 41 42--connection conn2 43set debug_sync = "now wait_for ready_to_mark_cf_dropped_in_create_cfs"; 44set @@global.rocksdb_delete_cf = 'cf_secondary_key'; 45 46set debug_sync = "now signal mark_cf_dropped_done_in_create_cfs"; 47 48# add index fails because cf_secondary_key has been marked as dropped 49--connection conn1 50--error ER_CF_DROPPED 51reap; 52 53show create table t1; 54 55select count(*) > 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key' ; 56set debug_sync = "now signal ready_to_drop_cf"; 57set debug_sync = "now wait_for drop_cf_done"; 58select count(*) = 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key'; 59 60set @@global.debug = @old_debug; 61 62## test2 ## 63--connection conn1 64set @@global.debug = '+d,rocksdb_inplace_populate_sk'; 65set @@global.debug = '+d,rocksdb_drop_cf'; 66 67send alter table t1 add index secondary_key (id2) comment 'cf_secondary_key'; 68 69--connection conn2 70set debug_sync = "now wait_for ready_to_mark_cf_dropped_in_populate_sk"; 71set @@global.rocksdb_delete_cf = 'cf_secondary_key'; 72 73set debug_sync = "now signal mark_cf_dropped_done_in_populate_sk"; 74 75# add index fails because cf_secondary_key has been marked as dropped 76--connection conn1 77--error ER_SK_POPULATE_DURING_ALTER 78reap; 79 80show create table t1; 81 82select count(*) > 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key' ; 83set debug_sync = "now signal ready_to_drop_cf"; 84set debug_sync = "now wait_for drop_cf_done"; 85select count(*) = 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key'; 86 87set @@global.debug = @old_debug; 88 89## test3 ## 90--connection conn1 91set @@global.debug = '+d,rocksdb_commit_alter_table'; 92set @@global.debug = '+d,rocksdb_drop_cf'; 93 94send alter table t1 add index secondary_key (id2) comment 'cf_secondary_key'; 95 96--connection conn2 97set debug_sync = "now wait_for ready_to_mark_cf_dropped_before_commit_alter_table"; 98 99# mark cf_secondary_key as dropped fails because it is in uncommitted_keydef 100--error ER_CANT_DROP_CF 101set @@global.rocksdb_delete_cf = 'cf_secondary_key'; 102 103set debug_sync = "now signal mark_cf_dropped_done_before_commit_alter_table"; 104 105--connection conn1 106# creation of the secondary key with cf cf_secondary_key succeeds 107reap; 108 109show create table t1; 110 111select count(*) > 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key' ; 112set debug_sync = "now signal ready_to_drop_cf"; 113set debug_sync = "now wait_for drop_cf_done"; 114select count(*) > 0 from information_schema.rocksdb_cfstats where cf_name = 'cf_secondary_key'; 115 116set @@global.debug = @old_debug; 117 118drop table t1; 119 120--connection default 121--disconnect conn1 122--disconnect conn2 123--source include/wait_until_count_sessions.inc 124