gh-ost icon indicating copy to clipboard operation
gh-ost copied to clipboard

Specify master directly when connecting to replica

Open dataindataout opened this issue 10 years ago • 34 comments

I see when using the "connect to replica, migrate on master" method, the master is detected via the function here https://github.com/github/gh-ost/blob/f06b469227208000d70739233fc222b1b4998f04/go/mysql/utils.go#L77.

Is there a way (that I've missed) to specify the master directly via a flag? If not, would making this configurable cause any architecture issues or predictable bugs?

Thank you!

dataindataout avatar Aug 30 '16 13:08 dataindataout

@dataindataout there is no way to do that right now. Adding this would not cause a significant architectural change.

Can you elaborate on the need?

The risk I see is someone wrongly specifying a master which is not on same topology (though gh-ost can presumably check it out)

shlomi-noach avatar Aug 30 '16 14:08 shlomi-noach

Or, another more likely risk is the user specifying a non-master server.

shlomi-noach avatar Aug 30 '16 14:08 shlomi-noach

Thank you for the reply! The use case would be non-native replication (e.g., Tungsten replicator), so a show slave status doesn't provide information. By the way, this is working functionally with the "Connect to master" method, of course.

dataindataout avatar Aug 30 '16 15:08 dataindataout

ahh... didn't cross my mind. Then, yes, it's possible. I might do this in the next week or two.

shlomi-noach avatar Aug 30 '16 16:08 shlomi-noach

Thank you for taking a look at it!

dataindataout avatar Aug 30 '16 16:08 dataindataout

@dataindataout out of curiosity, is your topology that uses tungsten strictly RBR?

shlomi-noach avatar Aug 30 '16 17:08 shlomi-noach

It's actually SBR (and can't be changed), so we've found that we do need to run it from a replica.

dataindataout avatar Aug 30 '16 17:08 dataindataout

@dataindataout I don't have a tungsten setup on me, could you please answer the following: if I were to look at one of your replica servers, replicating via tungsten, is there any indication at all in that server that it acts as a replica? I assume show slave status shows empty result. What would be a way for gh-ost (or any client) to say "oh yeah, this is a tungsten-based replica" ?

shlomi-noach avatar Sep 01 '16 09:09 shlomi-noach

Yes, show slave status is blank:

mysql> show slave status\G
Empty set (0.00 sec)

From mysql, you can see the tungsten connections, but of course there's no guarantee someone has named their user "tungsten":


mysql> show processlist\G
*************************** 1. row ***************************
           Id: 48
         User: tungsten
         Host: tungstenslave:52707
           db: tungsten_cookbook
      Command: Sleep
         Time: 2654
        State:
         Info: NULL
    Rows_sent: 0
Rows_examined: 0
    Rows_read: 0

There's nothing else we can think of or find within mysql to definitively indicated the slave is using tungsten.

If you hop out to the system level, you can see the tungsten java process running (ps aux | grep tungsten).

There are also tungsten tools at the system level like trepctl status. From a slave:

trepctl status | egrep 'role|pipeline'
pipelineSource         : thl://tungstenmaster:2112/
role                   : slave

Will any of these work?

dataindataout avatar Sep 01 '16 15:09 dataindataout

Thank you -- none of these would work from the MySQL connection's point of view. This is still OK; the command-line flag would need to be named something like --yes-i-know-i-know-this-is-tungsten-trust-me

shlomi-noach avatar Sep 01 '16 15:09 shlomi-noach

:)

dataindataout avatar Sep 01 '16 15:09 dataindataout

We have an active/passive replication setup, without tungsten (master-master, but only a single writer) and would also like to be able to specify or suggest which host is the master. Currently, gh-ost picks the wrong host.

pmkane avatar Sep 01 '16 21:09 pmkane

Being able to manually specify the master would also fix the master/master issues that I brought up in #144... :-)

Roguelazer avatar Sep 02 '16 03:09 Roguelazer

I implemented an -override-applier-host option, only allowed when you also pass -allow-master-master, and @pmkane tried it out successfully. I'll drop the code into a PR referencing this issue, though of course I get it if for design or other reasons it isn't what you want.

twotwotwo avatar Sep 02 '16 03:09 twotwotwo

@twotwotwo thank you for working on this!

Your solution will work for master-master setup, but does not quite solve the tungsten setup, because gh-ost will look at the replica and say "hey, this isn't a replica". We will need to override that as well.

I'll look into it some more.

shlomi-noach avatar Sep 02 '16 07:09 shlomi-noach

Ah, got it, now I understand the thread better. Makes sense!

twotwotwo avatar Sep 02 '16 07:09 twotwotwo

@twotwotwo or -- not! Actually this produces the desired behavior. I'm going to merge the PR and change a couple things:

  • going to rename flag to --assume-master-host
  • will allow it to run even without master-master, so as to support tungsten. Though I still want to have some constraint. Looking further into.

shlomi-noach avatar Sep 02 '16 09:09 shlomi-noach

@dataindataout as per https://github.com/github/gh-ost/pull/223, you will execute:

gh-ost --tungsten --assume-master-host=the.master.com

shlomi-noach avatar Sep 02 '16 11:09 shlomi-noach

This will likely be merged and released early next week.

shlomi-noach avatar Sep 02 '16 11:09 shlomi-noach

Wow, thank you! I look forward to giving it a try.

dataindataout avatar Sep 02 '16 12:09 dataindataout