| 1 |
## This test-case was created for reproducing a Valgrind issue that occure |
| 2 |
# between two session, one lising all session and second that is authenticating. |
| 3 |
|
| 4 |
--source include/have_debug_sync.inc |
| 5 |
--source include/have_debug.inc |
| 6 |
--source include/xplugin_preamble.inc |
| 7 |
--source include/xplugin_create_user.inc |
| 8 |
|
| 9 |
--echo ## I. Reproduce race condition between authenticating session and listing |
| 10 |
--echo # session: |
| 11 |
--echo # 1. Create X Protocol session(X1) using "x_root" account and hang it while |
| 12 |
--echo # authenticating (sync point: syncpoint_xpl_switch_to_user_execute, syncpoint_xpl_switch_to_user_enter) |
| 13 |
--echo # 2. Create classic protocol session(C1) and list all session, |
| 14 |
--echo # hang it at "x_root" row generation |
| 15 |
--echo # 3. Ensure that X1, changes session user, after that wakeup C1 |
| 16 |
--echo # 4. Show at C1, processlist results |
| 17 |
--echo |
| 18 |
|
| 19 |
|
| 20 |
## Test Setup |
| 21 |
--let $xtest_file= $MYSQL_TMP_DIR/admin_ping_mysqlx.xpl |
| 22 |
|
| 23 |
--write_file $xtest_file |
| 24 |
SELECT 'ok'; |
| 25 |
EOF |
| 26 |
|
| 27 |
|
| 28 |
## Test execution |
| 29 |
|
| 30 |
--echo |
| 31 |
--echo # |
| 32 |
--echo # I.1 |
| 33 |
|
| 34 |
--let $debug_point= syncpoint_xpl_switch_to_user_enter |
| 35 |
--source include/add_debug_point.inc |
| 36 |
--let $debug_point= syncpoint_xpl_switch_to_user_execute |
| 37 |
--source include/add_debug_point.inc |
| 38 |
--let $debug_point= test_fill_proc_with_x_root |
| 39 |
--source include/add_debug_point.inc |
| 40 |
|
| 41 |
--exec_in_background $MYSQLXTEST -ux_root --password='' --ssl-mode=required --plain-auth --file=$xtest_file 2>&1 |
| 42 |
|
| 43 |
# The X Plugin assignes the account several times, thus we skip first one |
| 44 |
# and hand on second switch |
| 45 |
SET SESSION DEBUG_SYNC="now WAIT_FOR reached_xpl_switch_to_user_enter"; |
| 46 |
SET SESSION DEBUG_SYNC="now SIGNAL continue_xpl_switch_to_user_enter"; |
| 47 |
SET SESSION DEBUG_SYNC="now WAIT_FOR reached_xpl_switch_to_user_execute"; |
| 48 |
SET SESSION DEBUG_SYNC="now SIGNAL continue_xpl_switch_to_user_execute"; |
| 49 |
|
| 50 |
|
| 51 |
--echo |
| 52 |
--echo # |
| 53 |
--echo # I.2 |
| 54 |
# Switch to mysql.session localhost, stop in middle and list sessions |
| 55 |
# |
| 56 |
# Depending on the fix, 'x_root' account might be missing at the list |
| 57 |
# for this case lets ensure that we always emit 'reached_sql_show' signal |
| 58 |
SET SESSION DEBUG_SYNC="now WAIT_FOR reached_xpl_switch_to_user_enter"; |
| 59 |
|
| 60 |
--connect(con_async,localhost,root,,test) |
| 61 |
SET SESSION DEBUG_SYNC="fill_proc_list_ended SIGNAL reached_sql_show"; |
| 62 |
SET SESSION DEBUG_SYNC="fill_proc_list_with_x_root SIGNAL reached_sql_show WAIT_FOR continue_sql_show"; |
| 63 |
send SELECT IF(count(user),"Grater than zero", "None") as NoClients from information_schema.processlist order by user; |
| 64 |
|
| 65 |
|
| 66 |
--echo |
| 67 |
--echo # |
| 68 |
--echo # I.3 |
| 69 |
--connection default |
| 70 |
|
| 71 |
SET SESSION DEBUG_SYNC="now WAIT_FOR reached_sql_show"; |
| 72 |
SET SESSION DEBUG_SYNC="now SIGNAL continue_xpl_switch_to_user_enter"; |
| 73 |
SET SESSION DEBUG_SYNC="now WAIT_FOR reached_xpl_switch_to_user_execute"; |
| 74 |
SET SESSION DEBUG_SYNC="now SIGNAL continue_sql_show"; |
| 75 |
|
| 76 |
|
| 77 |
--echo |
| 78 |
--echo # |
| 79 |
--echo # I.4 |
| 80 |
--connection con_async |
| 81 |
--reap |
| 82 |
--disconnect con_async |
| 83 |
--source include/wait_until_disconnected.inc |
| 84 |
--connection default |
| 85 |
|
| 86 |
|
| 87 |
## Cleanup |
| 88 |
--let $debug_point= syncpoint_xpl_switch_to_user_enter |
| 89 |
--source include/remove_debug_point.inc |
| 90 |
--let $debug_point= syncpoint_xpl_switch_to_user_execute |
| 91 |
--source include/remove_debug_point.inc |
| 92 |
--let $debug_point= test_fill_proc_with_x_root |
| 93 |
--source include/remove_debug_point.inc |
| 94 |
|
| 95 |
SET SESSION DEBUG_SYNC="now SIGNAL continue_xpl_switch_to_user_execute"; |
| 96 |
# No socket should be reported by X Plugin before user is dropped |
| 97 |
let $wait_condition= |
| 98 |
SELECT count(*)= 0 as Num FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection'; |
| 99 |
--source include/wait_condition_or_abort.inc |
| 100 |
|
| 101 |
SET SESSION DEBUG_SYNC="RESET"; |
| 102 |
|
| 103 |
--remove_file $xtest_file 30 |
| 104 |
--source ../include/xplugin_cleanup.inc |