1 # include/wait_until_count_sessions.inc
5 # Waits until the passed number ($count_sessions) of concurrent sessions or
6 # a smaller number was observed via
7 # SHOW STATUS LIKE 'Threads_connected'
8 # or the operation times out.
10 # 1. We wait for $current_sessions <= $count_sessions because in the use case
11 # with count_sessions.inc before and wait_until_count_sessions.inc after
12 # the core of the test it could happen that the disconnects of sessions
13 # belonging to the preceeding test are not finished.
14 # sessions at test begin($count_sessions) = m + n
15 # sessions of the previous test which will be soon disconnected = n (n >= 0)
16 # sessions at test end ($current sessions, assuming the test disconnects
17 # all additional sessions) = m
18 # 2. Starting with 5.1 we could also use
19 # SELECT COUNT(*) FROM information_schema.processlist
20 # I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
21 # runs in all versions 5.0+
26 # let $count_sessions= 3;
27 # --source include/wait_until_count_sessions.inc
29 # OR typical example of a test which uses more than one session
30 # Such a test could harm successing tests if there is no server shutdown
33 # If the testing box is slow than the disconnect of sessions belonging to
34 # the current test might happen when the successing test gets executed.
35 # This means the successing test might see activities like unexpected
36 # rows within the general log or the PROCESSLIST.
37 # Example from bug http://bugs.mysql.com/bug.php?id=40377
38 # --- bzr_mysql-6.0-rpl/.../r/log_state.result
39 # +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
41 # event_time user_host ... command_type argument
42 # TIMESTAMP USER_HOST ... Query create table t1(f1 int)
43 # TIMESTAMP USER_HOST ... Query select * from mysql.general_log
44 # +TIMESTAMP USER_HOST ... Quit
50 # # Determine initial number of connections (set $count_sessions)
51 # --source include/count_sessions.inc
53 # connect (con1,.....)
59 # # Wait until we have reached the initial number of connections
60 # # or more than the sleep time above (10 seconds) has passed.
62 # --source include/wait_until_count_sessions.inc
65 # Important note about tests with unfortunate (= not cooperative
66 # to successing tests) architecture:
68 # send SELECT ..., sleep(10)
75 # send SELECT ..., sleep(10)
83 # and not only by appending include/wait_until_count_sessions.inc etc.
88 # backup.test, grant3.test
94 # 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive,
98 let $wait_counter= 100;
101 let $wait_counter= `SELECT $wait_timeout * 10`;
103 # Reset $wait_timeout so that its value won't be used on subsequent
104 # calls, and default will be used instead.
105 let $wait_timeout= 0;
106 while ($wait_counter)
108 let $current_sessions= query_get_value(SHOW
STATUS LIKE
'Threads_connected', Value, 1);
109 let $success= `SELECT $current_sessions <= $count_sessions`;
112 let $wait_counter= 0;
122 --echo # Timeout in wait_until_count_sessions.inc
123 --echo #
Number of sessions expected: <= $count_sessions found: $current_sessions
125 --die Timeout in wait_until_count_sessions.inc