[MDEV-14182] Gtid_Slave_Pos is not reported equal using show variables or show all slaves status Created: 2017-10-28  Updated: 2020-12-01

Status: Confirmed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.0, 10.1, 10.2.9, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Major
Reporter: VAROQUI Stephane Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Definition of doc about show all slaves status

Gtid_Slave_Pos GTID of the last event group replicated on a slave server, for each replication domain, as stored in the gtid_slave_pos system variable. Returned with SHOW ALL SLAVES STATUS only.

MariaDB [(none)]> select version();
+----------------------------------------+
| version()                              |
+----------------------------------------+
| 10.2.9-MariaDB-10.2.9+maria~jessie-log |
+----------------------------------------+
 
MariaDB [(none)]> show global variables like 'gtid_sl%';
+----------------+-----------------+
| Variable_name  | Value           |
+----------------+-----------------+
| gtid_slave_pos | 0-3232261191-29 |
+----------------+-----------------+

pager grep -i gtid_slave_pos
PAGER set to 'grep -i gtid_slave_pos'
MariaDB [(none)]> show all slaves status\G
               Gtid_Slave_Pos: 0-3232261190-30

A list of binlog events in the slave that show some writes happen on it on top of replication events
https://pastebin.com/Mvg7uCKv

Not using multi domain
Not using strict mode



 Comments   
Comment by Elena Stepanova [ 2017-10-30 ]

Thanks for the report.

This is easily reproducible on 10.x. From the look of it, Gtid_Slave_Pos in SHOW ALL SLAVES STATUS shows all positions, not only those that have been replicated, but also those applied on the slave directly, while @@gtid_slave_pos only shows the replicated ones. Maybe it's meant to be this way, and this is just a documentation issue – in this case, Elkin, please re-categorize and re-assign.

The test case below only applicable to 10.1 and 10.2, because 10.0 does not have include/show_all_slaves_status.inc, but otherwise the versions have identical behavior.
I've changed the domain ID on the slave to indicate that it's not a race condition of any sort, but a clear matter of storing or not soring GTIDs created on the slave.

--source include/master-slave.inc
--source include/have_binlog_format_mixed.inc
 
--connection slave
STOP SLAVE;
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
START SLAVE;
 
--connection master
create or replace view v as select 1;
create or replace view v as select 2;
 
--sync_slave_with_master
 
set gtid_domain_id=100;
create or replace view v as select 3;
 
--let $status_items= Gtid_Slave_Pos
--source include/show_all_slaves_status.inc
show global variables like 'gtid_sl%';

Output

[connection master]
STOP SLAVE;
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
START SLAVE;
create or replace view v as select 1;
create or replace view v as select 2;
set gtid_domain_id=100;
create or replace view v as select 3;
Gtid_Slave_Pos = '0-1-2,100-2-1'
show global variables like 'gtid_sl%';
Variable_name	Value
gtid_slave_pos	0-1-2

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