[MDEV-23854] Query "flush binary logs delete_domain_id" succeeded, while error is expected Created: 2020-09-30  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Alice Sherepa Assignee: Andrei Elkin
Resolution: Unresolved Votes: 2
Labels: None


 Description   

test comes partly from rpl_gtid_delete_domain.test.

After discarding GTID domain from the server's binary log state,
if next 1 event is from that domain and then trying to discard it again - no error is shown, logs are flushed.

--source include/have_log_bin.inc
 
SET @@SESSION.gtid_domain_id=0;
CREATE TABLE t (a INT);
 
SET @@SESSION.gtid_domain_id=11;
SET @@SESSION.server_id=111;
SET @@SESSION.gtid_seq_no=1;
 
INSERT INTO t SET a=1;
 
# error is expected as there is "GTID 11-111-1" in the log
--error 1076 
 FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
 
show binlog events in 'master-bin.000001';
FLUSH BINARY LOGS;
show binlog events in 'master-bin.000002';
 
# error is expected as there is Gtid_list	[11-111-1,0-1-1]
--error 1076 
 FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
 
#now we purge logs to be able to do FLUSH BINARY LOGS DELETE_DOMAIN_ID:
 
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
--eval PURGE BINARY LOGS TO '$purge_to_binlog';
 
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
 
SELECT @@global.gtid_binlog_pos, @@global.gtid_binlog_state;
INSERT INTO t SET a=1; 
 
# session.gtid_domain_id is still 11, so it is logged as GTID 11-111-1
show binlog events in 'master-bin.000003';
SELECT @@global.gtid_binlog_pos, @@global.gtid_binlog_state;
 
# Here error 1076 is expected, but logs are flushed instead.
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
 
show master status;
show binlog events in 'master-bin.000004';
 
# if there is GTID 11-111-2 or more, then again error as expected 
INSERT INTO t SET a=1; 
INSERT INTO t SET a=1; 
 
show binlog events in 'master-bin.000004';
--error 1076 
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);

SET @@SESSION.gtid_domain_id=0;
CREATE TABLE t (a INT);
SET @@SESSION.gtid_domain_id=11;
SET @@SESSION.server_id=111;
SET @@SESSION.gtid_seq_no=1;
INSERT INTO t SET a=1;
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('11') being deleted. Make sure to first purge those files.
show binlog events in 'master-bin.000001';
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	4	Format_desc	1	256	Server ver: 10.2.34-MariaDB-debug-log, Binlog ver: 4
master-bin.000001	256	Gtid_list	1	285	[]
master-bin.000001	285	Binlog_checkpoint	1	329	master-bin.000001
master-bin.000001	329	Gtid	1	371	GTID 0-1-1
master-bin.000001	371	Query	1	460	use `test`; CREATE TABLE t (a INT)
master-bin.000001	460	Gtid	111	502	BEGIN GTID 11-111-1
master-bin.000001	502	Query	111	590	use `test`; INSERT INTO t SET a=1
master-bin.000001	590	Query	111	663	COMMIT
FLUSH BINARY LOGS;
show binlog events in 'master-bin.000002';
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	4	Format_desc	1	256	Server ver: 10.2.34-MariaDB-debug-log, Binlog ver: 4
master-bin.000002	256	Gtid_list	1	315	[11-111-1,0-1-1]
master-bin.000002	315	Binlog_checkpoint	1	359	master-bin.000001
master-bin.000002	359	Binlog_checkpoint	1	403	master-bin.000002
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('11') being deleted. Make sure to first purge those files.
PURGE BINARY LOGS TO 'master-bin.000002';;
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
SELECT @@global.gtid_binlog_pos, @@global.gtid_binlog_state;
@@global.gtid_binlog_pos	@@global.gtid_binlog_state
0-1-1	0-1-1
INSERT INTO t SET a=1;
show binlog events in 'master-bin.000003';
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000003	4	Format_desc	1	256	Server ver: 10.2.34-MariaDB-debug-log, Binlog ver: 4
master-bin.000003	256	Gtid_list	1	299	[0-1-1]
master-bin.000003	299	Binlog_checkpoint	1	343	master-bin.000002
master-bin.000003	343	Binlog_checkpoint	1	387	master-bin.000003
master-bin.000003	387	Gtid	111	429	BEGIN GTID 11-111-1
master-bin.000003	429	Query	111	517	use `test`; INSERT INTO t SET a=1
master-bin.000003	517	Query	111	590	COMMIT
SELECT @@global.gtid_binlog_pos, @@global.gtid_binlog_state;
@@global.gtid_binlog_pos	@@global.gtid_binlog_state
0-1-1,11-111-1	0-1-1,11-111-1
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
show master status;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000004	387		
show binlog events in 'master-bin.000004';
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000004	4	Format_desc	1	256	Server ver: 10.2.34-MariaDB-debug-log, Binlog ver: 4
master-bin.000004	256	Gtid_list	1	299	[0-1-1]
master-bin.000004	299	Binlog_checkpoint	1	343	master-bin.000003
master-bin.000004	343	Binlog_checkpoint	1	387	master-bin.000004
INSERT INTO t SET a=1;
INSERT INTO t SET a=1;
show binlog events in 'master-bin.000004';
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000004	4	Format_desc	1	256	Server ver: 10.2.34-MariaDB-debug-log, Binlog ver: 4
master-bin.000004	256	Gtid_list	1	299	[0-1-1]
master-bin.000004	299	Binlog_checkpoint	1	343	master-bin.000003
master-bin.000004	343	Binlog_checkpoint	1	387	master-bin.000004
master-bin.000004	387	Gtid	111	429	BEGIN GTID 11-111-1
master-bin.000004	429	Query	111	517	use `test`; INSERT INTO t SET a=1
master-bin.000004	517	Query	111	590	COMMIT
master-bin.000004	590	Gtid	111	632	BEGIN GTID 11-111-2
master-bin.000004	632	Query	111	720	use `test`; INSERT INTO t SET a=1
master-bin.000004	720	Query	111	793	COMMIT
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(11);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('11') being deleted. Make sure to first purge those files.


Generated at Thu Feb 08 09:25:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.