Debian Codegraph @

mysql-test/suite/x/t/message_io_error.test

raw
1 ## Preamble
2 --source include/xplugin_preamble.inc
3 --source include/xplugin_create_user.inc
4
5 ## TEST STARTS HERE
6 --write_file $MYSQL_TMP_DIR/validate_not_init_message.xpl
7 -->import wait_until_disconnect.macro
8
9 -->echo ## 1. Trigger disconnection in middle of X Message
10 -->echo #
11 # This test ensures that in case of IO error currently parsed protobuf
12 # message is discarded by the server. To do so we need to preapre
13 # a StmtExecute mesage with two fields "stmt" and "namespace".
14 #
15 # It will create a xprotocol frame with both fields, and its going
16 # to send it still, we will transfer successfully only "stmt",
17 # at "namespace" server is going to receive an IO error.
18 #
19 # Without the "namespace" the message could be interpreted
20 # as SQL "ping" (not the admin-command "ping").
21 #
22
23 #
24 # Binary form of message StmtExecute(SELECT 1) message:
25 -->varlet %MSG_LENGTH% \x0f\x00\x00\x00
26 -->varlet %MSG_TYPE% \x0c
27 -->varlet %MSG_BODY_FIELD1% \x0a\x04ping
28 -->varlet %MSG_BODY_FIELD2% \x1a\x06mysqlx
29
30
31 ## Optionaly following silent verification of the payload
32 ## can be uncommented:
33 #
34 #->binparse %MSG% Mysqlx.Sql.StmtExecute
35 # stmt: "ping"
36 # namespace: "mysqlx"
37 #}
38 #
39 ## Silent varification of %MSG_LENGTH% %MSG_TYPE% %MSG_BODY%
40 ## Verification of correctness binary form of message
41 #-->assert_eq %MSG% %MSG_LENGTH%%MSG_TYPE%%MSG_BODY_FIELD1%%MSG_BODY_FIELD2%
42 #
43
44 echo ## Send the message, without MSG_BODY_FIELD2;
45 echo #;
46 -->binsend %MSG_LENGTH%%MSG_TYPE%%MSG_BODY_FIELD1%
47
48 echo ## Drop the connection in middle of the message;
49 echo #;
50 -->closesession abort
51 EOF
52
53 # Set the timeout for connection to 300 seconds
54 # which is must be greater than the peerdisc/timeout
55 SET GLOBAL mysqlx_connect_timeout = 300;
56 SET GLOBAL mysqlx_wait_timeout = 300;
57
58 --let $wait_condition= SELECT variable_value = 0 FROM performance_schema.global_status WHERE variable_name LIKE 'Mysqlx_sessions_fatal_error'
59 --source include/wait_condition_or_abort.inc
60
61 --exec $MYSQLXTEST -u x_root --file=$MYSQL_TMP_DIR/validate_not_init_message.xpl 2>&1
62
63 echo ## 2. Verify that no StmtExecute was handled;
64 echo #;
65 echo #;
66
67 echo # Wait until the session is dropped;
68 echo #;
69 --let $wait_condition= SELECT variable_value = 0 FROM performance_schema.global_status WHERE variable_name LIKE 'Mysqlx_sessions'
70 --source include/wait_condition_or_abort.inc
71
72 echo # After that verify that non of StmtExecutes was processed;
73 echo #;
74 --let $wait_for_status_value=0,0,0
75 --let $wait_for_status_variable='Mysqlx_stmt_execute_sql','Mysqlx_stmt_execute_mysqlx','Mysqlx_stmt_execute_xplugin'
76 --source ../include/wait_for_status_variables.inc
77
78 ## Cleanup
79 SET GLOBAL mysqlx_connect_timeout= DEFAULT;
80 SET GLOBAL mysqlx_wait_timeout = DEFAULT;
81 --source ../include/xplugin_cleanup.inc