summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb_bugs/t/db938.test
blob: f1912faad026077972ebd9e014499cd8ef4a7205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This test for DB-938 tests a race condition where a scheduled background job
# (analyze) ends up operating on a set of DB* key_file[] in TOKUDB_SHARE that
# were set to NULL during a TRUNCATE TABLE operation.

-- source include/have_tokudb.inc
-- source include/have_debug.inc
-- source include/have_debug_sync.inc

-- enable_query_log

set @orig_auto_analyze = @@session.tokudb_auto_analyze;
set @orig_in_background = @@session.tokudb_analyze_in_background;
set @orig_mode = @@session.tokudb_analyze_mode;
set @orig_throttle = @@session.tokudb_analyze_throttle;
set @orig_time = @@session.tokudb_analyze_time;
set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent;
set @orig_default_storage_engine = @@session.default_storage_engine;
set @orig_pause_background_job_manager = @@global.tokudb_debug_pause_background_job_manager;

# first, lets set up to auto analyze in the background with about any activity
set session default_storage_engine = 'tokudb';
set session tokudb_auto_analyze = 1;
set session tokudb_analyze_in_background = 1;
set session tokudb_analyze_mode = tokudb_analyze_standard;
set session tokudb_analyze_throttle = 0;
set session tokudb_analyze_time = 0;
set global tokudb_cardinality_scale_percent = DEFAULT;

# in debug build, we can prevent the background job manager from running,
# let's do it to hold a job from running until we get the TRUNCATE TABLE
# in action
set global tokudb_debug_pause_background_job_manager = TRUE;

create table t1 (a int not null auto_increment, b int, c int, primary key(a), key kb(b), key kc(c), key kabc(a,b,c), key kab(a,b), key kbc(b,c));

insert into t1(b,c) values(0,0), (1,1), (2,2), (3,3);

# insert above should have triggered an analyze, but since the bjm is paused,
# we will see it sitting in the queue
select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status;

# lets flip to another connection
connect(conn1, localhost, root);

# set up the DEBUG_SYNC point
set DEBUG_SYNC = 'tokudb_after_truncate_all_dictionarys SIGNAL closed WAIT_FOR done';

# send the truncat table
send TRUNCATE TABLE t1;

# back to default connection
connection default;

# release the bjm
set global tokudb_debug_pause_background_job_manager = FALSE;

# if the bug is present, the bjm should crash here within 1/4 of a second
sleep 5;

# lets release and clean up
set DEBUG_SYNC = 'now SIGNAL done';

connection conn1;
reap;
connection default;
disconnect conn1;
drop table t1;

set session tokudb_auto_analyze = @orig_auto_analyze;
set session tokudb_analyze_in_background = @orig_in_background;
set session tokudb_analyze_mode = @orig_mode;
set session tokudb_analyze_throttle = @orig_throttle;
set session tokudb_analyze_time = @orig_time;
set global tokudb_cardinality_scale_percent = @orig_scale_percent;
set session default_storage_engine = @orig_default_storage_engine;
set global tokudb_debug_pause_background_job_manager = @orig_pause_background_job_manager;