Skip to content

Commit d8974eb

Browse files
committed
MDEV-14431 binlog.binlog_flush_binlogs_delete_domain failed in buildbot
The test and also rpl_gtid_delete_domain failed on PPC64 platform due to an incorrectly specified actual key for searching in a gtid domain system hash. While the correct size is 32 bits the supplied value was 8 bytes of long int size on the platform. The problem became evident thanks to the big endiness which cut off the *least* significant part of the value field. Fixed with correcting a dynamic array initialization to hold now uint32 values as well as the values extraction for searching in the gtid domain system hash. A new added test ensures no overflowed values are accepted for deletion which prevents inadvertent action. Notice though MariaDB [test]> set @@session.gtid_domain_id=(1 << 32) + 1; MariaDB [test]> show warnings; +---------+------+--------------------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------------------+ | Warning | 1292 | Truncated incorrect gtid_domain_id value: '4294967297' | +---------+------+--------------------------------------------------------+ MariaDB [test]> select @@session.gtid_domain_id; +--------------------------+ | @@session.gtid_domain_id | +--------------------------+ | 4294967295 | +--------------------------+
1 parent 5a5bc21 commit d8974eb

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

mysql-test/suite/binlog/r/binlog_flush_binlogs_delete_domain.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ master-bin.000002 #
1717
SET @@SESSION.gtid_domain_id=1;
1818
SET @@SESSION.server_id=1;
1919
CREATE TABLE t (a int);
20+
SELECT @@GLOBAL.gtid_binlog_state, @@GLOBAL.gtid_binlog_pos;
21+
@@GLOBAL.gtid_binlog_state @@GLOBAL.gtid_binlog_pos
22+
1-1-1 1-1-1
23+
include/show_binlog_events.inc
24+
Log_name Pos Event_type Server_id End_log_pos Info
25+
master-bin.000001 # Rotate # # master-bin.000002;pos=POS
2026
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
2127
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files.
2228
FLUSH BINARY LOGS;
@@ -74,5 +80,11 @@ the following command succeeds with warnings
7480
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
7581
Warnings:
7682
Warning 1076 The current gtid binlog state is incompatible with a former one having a gtid '11-11-1' which is less than the '11-11-11' of the gtid list describing an earlier state. The state may have been affected by manually injecting a lower sequence number gtid or via replication.
83+
RESET MASTER;
84+
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (4294967296);
85+
ERROR HY000: The value of gtid domain being deleted ('4294967296') exceeds its maximum size of 32 bit unsigned integer
86+
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (4294967295);
87+
Warnings:
88+
Warning 1076 The gtid domain being deleted ('4294967295') is not in the current binlog state
7789
DROP TABLE t;
7890
RESET MASTER;

mysql-test/suite/binlog/t/binlog_flush_binlogs_delete_domain.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ FLUSH BINARY LOGS DELETE_DOMAIN_ID = (99);
2828
SET @@SESSION.gtid_domain_id=1;
2929
SET @@SESSION.server_id=1;
3030
CREATE TABLE t (a int);
31+
SELECT @@GLOBAL.gtid_binlog_state, @@GLOBAL.gtid_binlog_pos;
32+
--let $binlog_start=
33+
--source include/show_binlog_events.inc
3134

3235
--error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
3336
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
@@ -129,6 +132,22 @@ SELECT @gtid_binlog_state_saved "as original state", @@GLOBAL.gtid_binlog_state
129132
--echo the following command succeeds with warnings
130133
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($del_d_id)
131134

135+
# cleanup: forget the out-of-order
136+
RESET MASTER;
137+
138+
#
139+
# MDEV-14431
140+
# Check rejection to delete a domain with value exceeding its range's maximum
141+
#
142+
--let $d_max_plus_1=`SELECT 1 << 32`
143+
--error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
144+
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($d_max_plus_1)
145+
146+
# accepted maximum:
147+
--let $d_max=`SELECT (1 << 32) - 1`
148+
--error 0
149+
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($d_max)
150+
132151
#
133152
# Cleanup
134153
#

sql/rpl_gtid.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,10 +1846,10 @@ rpl_binlog_state::drop_domain(DYNAMIC_ARRAY *ids,
18461846
for (ulong i= 0; i < ids->elements; i++)
18471847
{
18481848
rpl_binlog_state::element *elem= NULL;
1849-
ulong *ptr_domain_id;
1849+
uint32 *ptr_domain_id;
18501850
bool not_match;
18511851

1852-
ptr_domain_id= (ulong*) dynamic_array_ptr(ids, i);
1852+
ptr_domain_id= (uint32*) dynamic_array_ptr(ids, i);
18531853
elem= (rpl_binlog_state::element *)
18541854
my_hash_search(&hash, (const uchar *) ptr_domain_id, 0);
18551855
if (!elem)
@@ -1870,7 +1870,7 @@ rpl_binlog_state::drop_domain(DYNAMIC_ARRAY *ids,
18701870

18711871
if (not_match)
18721872
{
1873-
sprintf(errbuf, "binlog files may contain gtids from the domain ('%lu') "
1873+
sprintf(errbuf, "binlog files may contain gtids from the domain ('%u') "
18741874
"being deleted. Make sure to first purge those files",
18751875
*ptr_domain_id);
18761876
errmsg= errbuf;

sql/sql_lex.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ LEX::LEX()
28822882
INITIAL_LEX_PLUGIN_LIST_SIZE, 0);
28832883
reset_query_tables_list(TRUE);
28842884
mi.init();
2885-
init_dynamic_array2(&delete_gtid_domain, sizeof(ulong*),
2885+
init_dynamic_array2(&delete_gtid_domain, sizeof(uint32),
28862886
gtid_domain_static_buffer,
28872887
initial_gtid_domain_buffer_size,
28882888
initial_gtid_domain_buffer_size, 0);

sql/sql_lex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,7 @@ struct LEX: public Query_tables_list
27522752
*/
27532753
DYNAMIC_ARRAY delete_gtid_domain;
27542754
static const ulong initial_gtid_domain_buffer_size= 16;
2755-
ulong gtid_domain_static_buffer[initial_gtid_domain_buffer_size];
2755+
uint32 gtid_domain_static_buffer[initial_gtid_domain_buffer_size];
27562756

27572757
inline void set_limit_rows_examined()
27582758
{

sql/sql_yacc.yy

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12829,9 +12829,18 @@ delete_domain_id_list:
1282912829
;
1283012830

1283112831
delete_domain_id:
12832-
ulong_num
12832+
ulonglong_num
1283312833
{
12834-
insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &($1));
12834+
uint32 value= (uint32) $1;
12835+
if ($1 > UINT_MAX32)
12836+
{
12837+
my_printf_error(ER_BINLOG_CANT_DELETE_GTID_DOMAIN,
12838+
"The value of gtid domain being deleted ('%llu') "
12839+
"exceeds its maximum size "
12840+
"of 32 bit unsigned integer", MYF(0), $1);
12841+
MYSQL_YYABORT;
12842+
}
12843+
insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &value);
1283512844
}
1283612845
;
1283712846

0 commit comments

Comments
 (0)