-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
go/mysql: Fix MariadbGTIDSet multi-domain support. #6184
Conversation
This fixes two bugs: 1. AddGTID was mutating the original set. GTIDSet implementations are supposed to be immutable. 2. AddGTID and parseMariadbGTIDSet did not enforce any order among domains, yet Equal and other functions expected order to be enforced. This switches from a list to a map to better represent the fact that the order of domains doesn't matter, which also simplifies some code. We always enforce order when serializing back to a string. Signed-off-by: Anthony Yeh <enisoc@planetscale.com>
@deepthi I got the tests fixed so this is ready for review now. @PrismaPhonic I can't add you as a reviewer, but I'd appreciate if you can take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Domain monotonically increasing in the Position
string we get from MariaDB? If we parse that string into GTID and convert back to string, do we get back the same value?
It looks that way in the examples I've seen in the docs, but I haven't found any documented guarantee that it's always the case.
Given the above, we can't be sure, short of checking the MariaDB code. Are you thinking of a case in which it might be a problem to send back a sorted value when given an out-of-order value? |
Right. Anywhere where we do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Do you think it would be a problem to hand back the domains in a different order? I would assume MariaDB internally parses and/or compares them in such a way that order doesn't matter, though I haven't found documented proof of this. |
I don't know. We could test it by running a vitess cluster on mariadb. |
This fixes two bugs:
AddGTID was mutating the original set. GTIDSet implementations are
supposed to be immutable.
AddGTID and parseMariadbGTIDSet did not enforce any order among
domains, yet Equal and other functions expected order to be enforced.
This switches from a list to a map to better represent the fact that the order of domains doesn't matter, which also simplifies some code. We always enforce order when serializing back to a string.