mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
cc05440836
Some of the test cases reference to binlog position and these position numbers are written into result explicitly. It is difficult to maintain if log event format changes. There are a couple of cases explicit position number appears, we handle them in different ways A. 'CHANGE MASTER ...' with MASTER_LOG_POS or/and RELAY_LOG_POS options Use --replace_result to mask them. B. 'SHOW BINLOG EVENT ...' Replaced by show_binlog_events.inc or wait_for_binlog_event.inc. show_binlog_events.inc file's function is enhanced by given $binlog_file and $binlog_limit. C. 'SHOW SLAVE STATUS', 'show_slave_status.inc' and 'show_slave_status2.inc' For the test cases just care a few items in the result of 'SHOW SLAVE STATUS', only the items related to each test case are showed. 'show_slave_status.inc' is rebuild, only the given items in $status_items will be showed. 'check_slave_is_running.inc' and 'check_slave_no_error.inc' and 'check_slave_param.inc' are auxiliary files helping to show running status and error information easily.
127 lines
4.1 KiB
PHP
127 lines
4.1 KiB
PHP
# include/wait_until_count_sessions.inc
|
|
#
|
|
# SUMMARY
|
|
#
|
|
# Waits until the passed number ($count_sessions) of concurrent sessions or
|
|
# a smaller number was observed via
|
|
# SHOW STATUS LIKE 'Threads_connected'
|
|
# or the operation times out.
|
|
# Note:
|
|
# 1. We wait for $current_sessions <= $count_sessions because in the use case
|
|
# with count_sessions.inc before and wait_until_count_sessions.inc after
|
|
# the core of the test it could happen that the disconnects of sessions
|
|
# belonging to the preceeding test are not finished.
|
|
# sessions at test begin($count_sessions) = m + n
|
|
# sessions of the previous test which will be soon disconnected = n (n >= 0)
|
|
# sessions at test end ($current sessions, assuming the test disconnects
|
|
# all additional sessions) = m
|
|
# 2. Starting with 5.1 we could also use
|
|
# SELECT COUNT(*) FROM information_schema.processlist
|
|
# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
|
|
# runs in all versions 5.0+
|
|
#
|
|
#
|
|
# USAGE
|
|
#
|
|
# let $count_sessions= 3;
|
|
# --source include/wait_until_count_sessions.inc
|
|
#
|
|
# OR typical example of a test which uses more than one session
|
|
# Such a test could harm successing tests if there is no server shutdown
|
|
# and start between.
|
|
#
|
|
# If the testing box is slow than the disconnect of sessions belonging to
|
|
# the current test might happen when the successing test gets executed.
|
|
# This means the successing test might see activities like unexpected
|
|
# rows within the general log or the PROCESSLIST.
|
|
# Example from bug http://bugs.mysql.com/bug.php?id=40377
|
|
# --- bzr_mysql-6.0-rpl/.../r/log_state.result
|
|
# +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
|
|
# @@ -25,6 +25,7 @@
|
|
# event_time user_host ... command_type argument
|
|
# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
|
|
# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
|
|
# +TIMESTAMP USER_HOST ... Quit
|
|
# ....
|
|
#
|
|
# What to do?
|
|
# -----------
|
|
# <start of test>
|
|
# # Determine initial number of connections (set $count_sessions)
|
|
# --source include/count_sessions.inc
|
|
# ...
|
|
# connect (con1,.....)
|
|
# ...
|
|
# connection default;
|
|
# ...
|
|
# disconnect con1;
|
|
# ...
|
|
# # Wait until we have reached the initial number of connections
|
|
# # or more than the sleep time above (10 seconds) has passed.
|
|
# # $count_sessions
|
|
# --source include/wait_until_count_sessions.inc
|
|
# <end of test>
|
|
#
|
|
# Important note about tests with unfortunate (= not cooperative
|
|
# to successing tests) architecture:
|
|
# connection con1;
|
|
# send SELECT ..., sleep(10)
|
|
# connection default;
|
|
# ...
|
|
# disconnect con1;
|
|
# <end of test>
|
|
# should be fixed by
|
|
# connection con1;
|
|
# send SELECT ..., sleep(10)
|
|
# connection default;
|
|
# ...
|
|
# connect con1;
|
|
# reap;
|
|
# connection default;
|
|
# disconnect con1;
|
|
# <end of test>
|
|
# and not only by appending include/wait_until_count_sessions.inc etc.
|
|
#
|
|
#
|
|
# EXAMPLE
|
|
#
|
|
# backup.test, grant3.test
|
|
#
|
|
#
|
|
# Created:
|
|
# 2009-01-14 mleich
|
|
# Modified:
|
|
# 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive,
|
|
# random PB failures
|
|
#
|
|
|
|
let $wait_counter= 100;
|
|
if ($wait_timeout)
|
|
{
|
|
let $wait_counter= `SELECT $wait_timeout * 10`;
|
|
}
|
|
# Reset $wait_timeout so that its value won't be used on subsequent
|
|
# calls, and default will be used instead.
|
|
let $wait_timeout= 0;
|
|
while ($wait_counter)
|
|
{
|
|
let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
|
|
let $success= `SELECT $current_sessions <= $count_sessions`;
|
|
if ($success)
|
|
{
|
|
let $wait_counter= 0;
|
|
}
|
|
if (!$success)
|
|
{
|
|
real_sleep 0.1;
|
|
dec $wait_counter;
|
|
}
|
|
}
|
|
if (!$success)
|
|
{
|
|
--echo # Timeout in wait_until_count_sessions.inc
|
|
--echo # Number of sessions expected: <= $count_sessions found: $current_sessions
|
|
SHOW PROCESSLIST;
|
|
--die Timeout in wait_until_count_sessions.inc
|
|
}
|
|
|