Commit 44a901a
Venkatesh Duggirala
BUG#17650326 MYSQLBINLOG PRINTS INVALID SQL FROM RELAY LOGS WHEN GTID IS ENABLED
Problem (1) : Replaying a relaylog which ends with GTID_LOG_EVENT causes
error "ERROR 1790 (HY000) @@SESSION.GTID_NEXT cannot be changed by a client
that owns a GTID. The client owns <UUID:GTID> Ownership is released on
COMMIT or ROLLBACK."
Analysis: mysqlbinlog tool appends SET @@SESSION.GTID_NEXT='AUTOMATIC'
to output when it finds a rotate log event and if it is not inside
a transaction which is the right thing to do. The tool has in_transaction
flag which will be set true upon processing any transaction event.
But a GTID_LOG_EVENT is not treated as a transaction event,
hence in_transaction is false even after processing GTID_LOG_EVENT.
If a relaylog rotate happens (either through IO thread restart/ROTATE
command), exactly after writing GTID_LOG_EVENT and if we are replaying such a
relaylog's end ROTATE_EVENT, logic was mistakenly thinking that it was not
inside a transaction but actually the transaction was started after
GTID_LOG_EVENT. Hence tool generates SET @@SESSION.GTID_NEXT='AUTOMATIC'.
This issue resulted in having two GTID_NEXT statements next to each other and
replaying such output against 'mysql' client tool was causing above specified
error (ERROR:1790).
Fix: One way to fix this issue is to set in_transaction flag to true when it
encounters GTID_LOG_EVENT. But this change will disturb DDL transaction
detection logic (mysqlbinlog tool logic assumes that DDL transactions will
have only one event per transaction). So instead of disturbing that logic,
we have followed another approach to solve the issue. 'mysqlbinlog' tool
generates "SET @@SESSION.GTID_NEXT='AUTOMATIC'" only when in_transaction
is false and is_gtid_next_valid is false (which represents that we are
not in transaction and did not even see GTID_LOG_EVENT.
Problem (2): 'ROLLBACK' is not getting generated by mysqlbinlog tool
when concatenating and replaying two consecutive relaylogs
(the first relaylog contains partial transaction and second relaylog
contains full transaction again).
Analysis: If IO thread is restarted when it is in the middle of
transferring a tranasction from Master then it will retrieve the
full transaction again upon restart. In that case, the first relaylog
contains partial GTID transaction and the second relaylog will
contain full GTID transaction again. If mysqlbinlog tool is used
to merge such two relaylogs it should generate a 'ROLLBACK' statement
after partial transaction. Otherwise it will cause above said error
(ERROR:1790).
Fix: If IO thread is restarted, the new generated relaylog will have
FD event received from Master and will have log_pos greater than zero
if the AUTO_POSITION is true i.e., this will indicate that if we
were in transaction in first relaylog, Master would have sent the
transaction again from the beginning. In this case, upon reading such
a FD event, generate 'ROLLBACK' statement in generated output. If
we have seen only GTID_LOG_EVENT of the transaction and not seen
'BEGIN' statement, then generate BEGIN and ROLLBACK statements
in generated output.1 parent ba082ab commit 44a901a
File tree
5 files changed
+184
-3
lines changed- client
- mysql-test/suite/rpl
- r
- t
- sql
5 files changed
+184
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1090 | 1101 | | |
1091 | 1102 | | |
1092 | 1103 | | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
1093 | 1150 | | |
1094 | 1151 | | |
1095 | 1152 | | |
| |||
1331 | 1388 | | |
1332 | 1389 | | |
1333 | 1390 | | |
1334 | | - | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1335 | 1406 | | |
1336 | 1407 | | |
1337 | 1408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13781 | 13781 | | |
13782 | 13782 | | |
13783 | 13783 | | |
13784 | | - | |
| 13784 | + | |
13785 | 13785 | | |
13786 | 13786 | | |
13787 | 13787 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
| 791 | + | |
791 | 792 | | |
792 | 793 | | |
793 | 794 | | |
| |||
0 commit comments