Shopify / ghostferry

The swiss army knife of live data migrations
https://shopify.github.io/ghostferry
MIT License
759 stars 72 forks source link

Config value for copydb `ReplicatedMasterPositionQuery` with vanilla MysQL replication #348

Open jrichardlai opened 1 year ago

jrichardlai commented 1 year ago

Hello, I am trying to use the ReplicatedMasterPositionQuery config when setting the source as replica. The example in the config is showing a query using pt-heartbeat https://github.com/Shopify/ghostferry/blob/82e061559901f036a79c44c14ec5dbde67a7884a/copydb/config.go#L70 When using vanilla MySQL replication ( using 8.0.34 ), what query should I be using? It seems SHOW REPLICA STATUS; contains the adequate information ( Relay_Source_Log_Pos, Relay_Source_Log_File ), however I am not able to extract them through a SELECT query. Am I missing a config to use?

Looking into it, there are some tables related to replication in the performance schema https://dev.mysql.com/doc/refman/8.0/en/performance-schema-replication-tables.html, however it states the following:

The information in the Performance Schema replication tables differs somewhat from the information available from SHOW REPLICA STATUS because the tables are oriented toward use of global transaction identifiers (GTIDs), not file names and positions, and they represent server UUID values, not server ID values. Due to these differences, several SHOW REPLICA STATUS columns are not preserved in the Performance Schema replication tables, or are represented a different way:

The following fields refer to file names and positions and are not preserved:

Master_Log_File
Read_Master_Log_Pos
Relay_Log_File
Relay_Log_Pos
Relay_Master_Log_File
Exec_Master_Log_Pos
Until_Condition
Until_Log_File
Until_Log_Pos

So it does not seems that it could be used.

Thanks!