Bug #102005 Session tracker not reset itself when error affect next statement
Submitted: 16 Dec 2020 6:50 Modified: 16 Dec 2020 7:47
Reporter: ggwdwsbs W Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:8.0.22, 5.7, 5.7.32 OS:Any
Assigned to: CPU Architecture:Any

[16 Dec 2020 6:50] ggwdwsbs W
Description:
When session tracker track some non-atomicity statement(such as set system variables), part of them may success and part of them may fail. 

When this case happen, server will send error packet use net_send_error_packet(), and the session trackers are not reset. This will cause wrong session tracker information of next statement.

How to repeat:
Use the following test case to repeat, you can see the "select 1;" statement output session tracker information by wrong.

TESTCASE:

--enable_session_track_info
set session_track_system_variables = "*";
set session_track_schema = off;

--error ER_MALFORMED_GTID_SPECIFICATION
set session_track_schema = on, gtid_next = "123";
select 1;

OUTPUT:

set session_track_system_variables = "*";
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- session_track_system_variables
-- *

set session_track_schema = off;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- session_track_schema
-- OFF

set session_track_schema = on, gtid_next = "123";
ERROR HY000: Malformed GTID specification '123'.
select 1;
1
1
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- session_track_schema
-- ON

Suggested fix:
Reset the session tracker when the store() function have not been called and the tracker have been mark_as_changed.
[16 Dec 2020 7:47] MySQL Verification Team
Hello!

Thank you for the report and feedback.

regards,
Umesh