Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
MDEV-28487: sequences not respect value of binlog_row_image with sele…
…ct nextval(seq_gen) Problem: ======== When using sequences, the function sequence_definition::write(TABLE *table, bool all_fields) is used to save DML/DDL updates to sequence tables (e.g. nextval, setval, and alter). Prior to this patch, the value all_fields was always false when invoked via nextval and setval, which forced the bitmap to only include changed columns. Solution: ======== Change all_fields when invoked via nextval and setval to be reliant on binlog_row_image, such that it is false when binlog_row_image is MINIMAL, and true otherwise. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
- Loading branch information
Showing
6 changed files
with
2,546 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # | ||
| # Helper file to ensure that a binary log file properly writes the expected | ||
| # fields based on the binlog_row_image value. | ||
| # | ||
| # ==== Usage ==== | ||
| # | ||
| # --let $expected_columns= (COLUMN_IDS) | ||
| # --let $binlog_filename= FILENAME | ||
| # --source include/count_binlog_row_event_columns.inc | ||
| # | ||
| # Parameters: | ||
| # expected_columns (list<uint>, in) : A list of positive integers which | ||
| # correspond to the column numbers that should be output in a binary | ||
| # log's write_rows event | ||
| # binlog_filename (string, in) : Name of the binary log file to analyze | ||
| # | ||
| if (!$expected_columns) | ||
| { | ||
| --die expected_columns parameter is required but was not set | ||
| } | ||
| if (!$binlog_filename) | ||
| { | ||
| --die binlog_filename parameter is required but was not set | ||
| } | ||
| --let $include_filename= ensure_binlog_row_event_columns.inc [$expected_columns] | ||
| --source include/begin_include_file.inc | ||
| --let $assert_file=$MYSQLTEST_VARDIR/tmp/binlog_decoded.out | ||
| --let mysqld_datadir=`select @@datadir` | ||
| --echo # MYSQL_BINLOG mysqld_datadir/binlog_filename -vv > assert_file | ||
| --exec $MYSQL_BINLOG $mysqld_datadir/$binlog_filename -vv > $assert_file | ||
| --echo # Verifying all expected column ids appear in binlog event output.. | ||
| --let num_cols_found=0 | ||
| --let last_expected_col= `SELECT GREATEST $expected_columns` | ||
| --let i= 1 | ||
| while($i <= $last_expected_col) | ||
| { | ||
| # By default, assume the column is not expected to be in the binary log. | ||
| # If the column id is set in expected_columns, then override assertion | ||
| # parameters. | ||
| --let assert_count= 0 | ||
| --let assert_text= Column @$i should not be in binary log | ||
| if (`SELECT $i IN $expected_columns`) | ||
| { | ||
| --let assert_count= 1 | ||
| --let assert_text= Column @$i should be in binary log | ||
| --inc $num_cols_found | ||
| } | ||
| --let assert_select= @$i | ||
| --source include/assert_grep.inc | ||
| --inc $i | ||
| } | ||
| --echo # ..success | ||
| --echo # Verifying only expected column ids appear in binlog event output.. | ||
| --let assert_count= $num_cols_found | ||
| --let assert_text= The binlog event should only have $num_cols_found columns | ||
| --let assert_select= @[\d]+ | ||
| --source include/assert_grep.inc | ||
| --echo # ..success | ||
| --let $include_filename= ensure_binlog_row_event_columns.inc [$expected_columns] | ||
| --source include/end_include_file.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # | ||
| # This include file validates that sequence events are properly binlogged | ||
| # and replicated. | ||
| # | ||
| # Parameters: | ||
| # expected_columns (list<uint>, in) : A list of positive integers which | ||
| # correspond to the column numbers that should be output in a binary | ||
| # log's write_rows event | ||
| # | ||
|
|
||
| --echo # Create sequences with specific engines per server | ||
| --connection server_1 | ||
| --eval SET STATEMENT sql_log_bin=0 FOR create sequence s1 cache=0 engine=$server_1_engine | ||
| --source include/save_master_gtid.inc | ||
|
|
||
| --connection server_2 | ||
| --eval SET STATEMENT sql_log_bin=0 FOR create sequence s1 cache=0 engine=$server_2_engine | ||
| --source include/sync_with_master_gtid.inc | ||
|
|
||
| --connection server_3 | ||
| --eval SET STATEMENT sql_log_bin=0 FOR create sequence s1 cache=0 engine=$server_3_engine | ||
| --source include/sync_with_master_gtid.inc | ||
|
|
||
|
|
||
| --echo # Pt.1 Ensure SETVAL replicates and binlogs correctly | ||
| --connection server_1 | ||
| SELECT SETVAL(s1, 10); | ||
| --source include/save_master_gtid.inc | ||
|
|
||
| --echo # Validate SETVAL replicated correctly to other servers | ||
| --connection server_3 | ||
| --source include/sync_with_master_gtid.inc | ||
| --let $diff_tables= server_1:test.s1,server_2:test.s1,server_3:test.s1 | ||
| --source include/diff_tables.inc | ||
|
|
||
| --echo # Validate server_1 binlogged SETVAL with the correct columns | ||
| --connection server_1 | ||
| --let binlog_filenamE= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
| --echo # Validate server_2 binlogged SETVAL with the correct columns | ||
| --connection server_2 | ||
| --let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
| --echo # Validate server_3 binlogged SETVAL with the correct columns | ||
| --connection server_3 | ||
| --let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
|
|
||
| --echo # Pt.2 Ensure NEXTVAL replicates and binlogs correctly | ||
| --connection server_1 | ||
| SELECT NEXTVAL(s1); | ||
| --source include/save_master_gtid.inc | ||
|
|
||
| --echo # Validate NEXTVAL replicated correctly to other servers | ||
| --connection server_3 | ||
| --source include/sync_with_master_gtid.inc | ||
| --let $diff_tables= server_1:test.s1,server_2:test.s1,server_3:test.s1 | ||
| --source include/diff_tables.inc | ||
|
|
||
| --echo # Validate server_1 binlogged NEXTVAL with the correct columns | ||
| --connection server_1 | ||
| --let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
| --echo # Validate server_2 binlogged NEXTVAL with the correct columns | ||
| --connection server_2 | ||
| --let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
| --echo # Validate server_3 binlogged NEXTVAL with the correct columns | ||
| --connection server_3 | ||
| --let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| FLUSH LOGS; | ||
| --source include/ensure_binlog_row_event_columns.inc | ||
|
|
||
|
|
||
| --echo # Cleanup | ||
| --connection server_1 | ||
| DROP TABLE s1; | ||
| --source include/save_master_gtid.inc | ||
| --connection server_3 | ||
| --source include/sync_with_master_gtid.inc |
Oops, something went wrong.