Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharding: abort if target db becomes readonly before cutover #58

Merged
merged 1 commit into from
Aug 14, 2018

Conversation

hkdsun
Copy link
Contributor

@hkdsun hkdsun commented Aug 10, 2018

Follow up to #51

The rationale for this one is that it's too risky to go into the cutover phase if the target db is read-only anyway. It replaces a call that we previously did on the shop mover side.

@Shopify/pods

@@ -169,3 +169,10 @@ func NewMysqlPosition(file string, position uint32, err error) (mysql.Position,
}, nil
}
}

func CheckDbIsAReplica(db *sql.DB) (bool, error) {
row := db.QueryRow("SELECT @@read_only")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we thought about using SHOW SLAVE STATUS here instead of just relying on the @@read_only variable? It seems it is technically possible to run an async slave without setting this flag as MySQL doesn't force you to set read_only = ON. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shopify runs a master-master configuration which means masters from different location are slaving off each other (and hence SLAVE STATUS will show the slave thread on both instances). We're tracking making this configurable in #53

@hkdsun hkdsun merged commit cf9b9cc into master Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants