Pavel Ivanov <pivanof@google.com> writes:
As I understand GTID is constructed as <domain id>-<server id>-<sequence number>. Is it guaranteed that sequence numbers are always increasing inside the domain id? So
The intention is that the user/DBA should configure things so that there is only ever one active master for each domain_id. If this is done correctly (eg. all slaves are made read-only, no fiddling with manual queries on slaves), then sequence numbers will be unique globally per domain_id, and server_id is actually unnecessary. Because if some server is first a slave, and then is promoted to master, then it will continue the sequence numbering from the point of the last replicated GTID. However, it is easy for novice users/DBAs to get this incorrect. Maybe they just fiddle a little on a slave with some manual queries or something. One can usually get away with this with old-style replication, so I tried to make it work also for GTID, even though the recommended operation is one-master-per-domain. If a user transaction is done on a slave in parallel with an active master, then there is no way to avoid duplicate sequence number. The server_id then ensures that we can still distinguish the GTIDs from the different events. Basically, the code tries to make sequence numbers unique per domain, but also tries to avoid relying on this uniques for correct operation. (I have thought of making a strict mode for GTID, which will make the slave give an error if it detects non-unique sequence number. This would allow experienced DBA to enforce one-master-per-domain and catch misconfigurations (by setting strict mode), and also allow novice users to not concern themselves with this (by not setting strict mode).
let's say two servers have GTID 0-1-100 and if they have alternate futures then one server will have GTIDs 0-1-101, 0-1-102 and so on, while second server will have 0-2-101, 0-2-102 etc. Is that correct?
Yes (if I understand you correctly). Each server will continue the sequence numbering from whichever GTID was last seen.
BTW, where in the code is sequence number increased exactly?
In MYSQL_BIN_LOG::write_gtid_event(). - Kristian.