-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-40759: Fix --force-read crash on checksum-failing Format Description event #5552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| CREATE TABLE t1 (a INT); | ||
| INSERT INTO t1 VALUES (1); | ||
| /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; | ||
| /*!40019 SET @@session.max_delayed_threads=0*/; | ||
| /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; | ||
| DELIMITER /*!*/; | ||
| # at 4 | ||
| # Encrypted event | ||
| DELIMITER ; | ||
| # End of log file | ||
| ROLLBACK /* added by mysqlbinlog */; | ||
| /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; | ||
| /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; | ||
| /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; | ||
| /*!40019 SET @@session.max_delayed_threads=0*/; | ||
| /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; | ||
| DELIMITER /*!*/; | ||
| # at 4 | ||
| # Encrypted event | ||
| DELIMITER ; | ||
| # End of log file | ||
| ROLLBACK /* added by mysqlbinlog */; | ||
| /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; | ||
| /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; | ||
| DROP TABLE t1; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||||||||||||||||
| # MDEV-40759: mariadb-binlog --force-read --start-position crashes on | ||||||||||||||||||||||||
| # Unknown event | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # With --force-read, a Format Description event whose checksum is invalid is | ||||||||||||||||||||||||
| # returned as an Unknown_log_event instead of NULL (Log_event::read_log_event). | ||||||||||||||||||||||||
| # check_header()'s prelude wrongly treated such an event as a Format | ||||||||||||||||||||||||
| # Description event, which is undefined behaviour (a vptr error under UBSan) | ||||||||||||||||||||||||
| # and, in --base64-output modes other than AUTO, silently swallowed the event. | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # The checksum failure is simulated with --debug=d,simulate_checksum_test_failure. | ||||||||||||||||||||||||
| --source include/mysqlbinlog_have_debug.inc | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, what’s this? It’s not used in either
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It came from before the hard-forking and is never used… Personal opinion: It’s good that it’s not used, because it works by scanning the entire |
||||||||||||||||||||||||
| --source include/have_binlog_format_mixed.inc | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Grow the current binlog past the Format Description event so that | ||||||||||||||||||||||||
| # check_header()'s --start-position prelude has to read it. | ||||||||||||||||||||||||
| CREATE TABLE t1 (a INT); | ||||||||||||||||||||||||
|
Comment on lines
+14
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: A modern “blank” binlog is already past the FDE: There’s the GTID List, a Binlog Checkpoint for XA, maybe (forgot if there is) a Rotate. Manually growing the log is also fine, to not depend on those additional header events, especially since we do want to test with some manually controlled content below. |
||||||||||||||||||||||||
| INSERT INTO t1 VALUES (1); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| --let $MYSQL_DATADIR= `SELECT @@datadir` | ||||||||||||||||||||||||
| --let $binlog_file= query_get_value(SHOW BINLOG STATUS, File, 1) | ||||||||||||||||||||||||
| --let $binlog_start= query_get_value(SHOW BINLOG STATUS, Position, 1) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, you can smell how wrong it gets from how
Suggested change
In the final test, you can use the DROP below as the “content after |
||||||||||||||||||||||||
| # Must not crash, and must report the checksum-failing Format Description event. | ||||||||||||||||||||||||
| --exec $MYSQL_BINLOG --verify-binlog-checksum --force-read --debug=d,simulate_checksum_test_failure --start-position=$binlog_start $MYSQL_DATADIR/$binlog_file | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Must not silently drop the event when not in AUTO mode either. | ||||||||||||||||||||||||
| --exec $MYSQL_BINLOG --verify-binlog-checksum --force-read --base64-output=NEVER --debug=d,simulate_checksum_test_failure --start-position=$binlog_start $MYSQL_DATADIR/$binlog_file | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| DROP TABLE t1; | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your interest, but we do merge-ups instead of backports here, so please base your PR on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is new to me, but I’m not convinced.
A Format Description Event that’s invalid (whether because of a checksum mismatch or some other corruption) is still meant to describe the log’s format.
Both ignoring it and substituting with “a default” FDE would be very wrong (at least for the premise of this
check_header()function, in contrast to the dream where the default FDE is already sufficient).The only case this would not matter is when two FDEs appear back-to-back – this can only come from a handcrafted log, AFAIK.