On 2013-05-07 17:13, Kristian Nielsen wrote:
Alex Yurchenko <alexey.yurchenko@codership.com> writes:
From the documentation the purpose of domain ID in GTID is quite clear. But what is the role of server ID?
The role is mainly to ensure uniqueness of GTID when domain_id is not configured correctly.
Since both are configured manually, and domain ID can simply default to 0 in simple setups, I'd imagine that the possibility of having server ID configured incorrectly (just missing to configure it) is way more probable than having domain ID incorrect. Actually, being an arbitrary node group ID what is "incorrect" here? ANY value just makes the node a member of the corresponding domain, so ANY domain ID value is legal. Whereas server ID can certainly be incorrect (a duplicate within the domain).
Replication already requires server ID to be unique, so (server_id, sequence number) will be globally unique as long as sequence number is increased locally on each server.
Domain id is not required to be unique, in fact it will typically be shared by master and slave. It is a common mistake to do a manual transaction on the slave while transactions are also being done at the same time on the master. Having server_id in the GTID prevents that two different transactions end up with the same GTID.
So suppose we have nodes N0, N1 and N2 with IDs 0-0, 0-1, 0-2 respectively. Initially N1 and N2 both replicate from N0 and have identical DB contents. At 0-0-10 N2 goes to maintenance. After 0-0-100 someone executes local transaction on N1 and it gets logged as 0-1-101. Right? So if now N0 executes another transaction, what will be its GTID? a) on N0 - 0-0-101? b) on N1 - 0-0-102 or 0-0-101? (as your documentation states
The server ID is set to the server ID of the server where the event group is first logged into the binlog. The sequence number is increased on a server for every event group logged. So it is actually another question, sequence number is not set on the master server but always computed locally?)
Or, does N1 detect a problem at this point? If yes, how exactly? How server ID is involved there? Now if we can get past this point without an error at N1, and start N2 to replicate from N1, I take it will receive and commit 0-1-101. But will it ever record it somewhere or its state will be simply 0-0-XXX? If at 0-0-110 we failover N0 to replicate from N2, will it receive 0-1-101? Thanks, Alex
- Kristian.
-- Alexey Yurchenko, Codership Oy, www.codership.com Skype: alexey.yurchenko, Phone: +358-400-516-011