Skip to content

Commit df2754a

Browse files
committed
Merge branch 'master' into vendor-updates
2 parents cdbdaf6 + badd1a9 commit df2754a

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

docs/Manual/Upgrading/Starter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Starting from versions 3.2.15 and 3.3.8, the ArangoDB [_Starter_](../../Programs/Starter/README.md)
44
supports a new, automated, procedure to perform upgrades, including rolling upgrades
5-
of a [Cluster](../../Scalability/Cluster/README.md) setup.
5+
of a [Cluster](../../Architecture/DeploymentModes/README.md) setup.
66

77
The upgrade procedure of the _Starter_ described in this _Section_ can be used to
88
upgrade to a new hotfix, or to perform an upgrade to a new minor version of ArangoDB.

service/service.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,15 +900,30 @@ func (s *Service) HandleHello(ownAddress, remoteAddress string, req *HelloReques
900900
// ID already found, update peer data
901901
for i, p := range s.myPeers.AllPeers {
902902
if p.ID == req.SlaveID {
903-
s.myPeers.AllPeers[i].Port = req.SlavePort
904903
if s.cfg.AllPortOffsetsUnique {
905904
s.myPeers.AllPeers[i].Address = slaveAddr
906905
} else {
907-
// Slave address may not change
908-
if p.Address != slaveAddr {
906+
// Need to check if this particular address does appear in
907+
// another peer, if so, we forbid to change the address:
908+
addrFoundInOtherPeer := false
909+
for _, pp := range s.myPeers.AllPeers {
910+
if pp.ID != req.SlaveID && pp.Address == slaveAddr {
911+
addrFoundInOtherPeer = true
912+
break
913+
}
914+
}
915+
// Slave address may not change in this case
916+
if addrFoundInOtherPeer && p.Address != slaveAddr {
909917
return ClusterConfig{}, maskAny(client.NewBadRequestError("Cannot change slave address while using an existing ID."))
910918
}
919+
// We accept the new address (it might be the old one):
920+
s.myPeers.AllPeers[i].Address = slaveAddr
921+
// However, since we also accept the port, we must set the
922+
// port ofset of that replaced peer to 0 such that the AllPeers
923+
// information actually contains the right port.
924+
s.myPeers.AllPeers[i].PortOffset = 0
911925
}
926+
s.myPeers.AllPeers[i].Port = req.SlavePort
912927
s.myPeers.AllPeers[i].DataDir = req.DataDir
913928
}
914929
}

0 commit comments

Comments
 (0)