Esempio n. 1
0
func isGeneralyValidAsCandidateSiblingOfIntermediateMaster(sibling *inst.Instance) bool {
	if !sibling.LogBinEnabled {
		return false
	}
	if !sibling.LogSlaveUpdatesEnabled {
		return false
	}
	if !sibling.SlaveRunning() {
		return false
	}
	if !sibling.IsLastCheckValid {
		return false
	}
	return true
}
Esempio n. 2
0
func (s *TestSuite) TestIsSmallerMajorVersion(c *C) {
	i55 := inst.Instance{Version: "5.5"}
	i5517 := inst.Instance{Version: "5.5.17"}
	i56 := inst.Instance{Version: "5.6"}

	c.Assert(i55.IsSmallerMajorVersion(&i5517), Not(Equals), true)
	c.Assert(i56.IsSmallerMajorVersion(&i5517), Not(Equals), true)
	c.Assert(i55.IsSmallerMajorVersion(&i56), Equals, true)
}
Esempio n. 3
0
func isValidAsCandidateSiblingOfIntermediateMaster(intermediateMasterInstance *inst.Instance, sibling *inst.Instance) bool {
	if sibling.Key.Equals(&intermediateMasterInstance.Key) {
		// same instance
		return false
	}
	if !isGeneralyValidAsCandidateSiblingOfIntermediateMaster(sibling) {
		return false
	}
	if sibling.HasReplicationFilters != intermediateMasterInstance.HasReplicationFilters {
		return false
	}
	if sibling.IsMaxScale() || intermediateMasterInstance.IsMaxScale() {
		// With MaxScale the failover is different; we don't need this "move to uncle" logic.
		return false
	}
	if sibling.ExecBinlogCoordinates.SmallerThan(&intermediateMasterInstance.ExecBinlogCoordinates) {
		return false
	}
	return true
}
Esempio n. 4
0
func isValidAsCandidateSiblingOfIntermediateMaster(intermediateMasterInstance *inst.Instance, sibling *inst.Instance) bool {
	if sibling.Key.Equals(&intermediateMasterInstance.Key) {
		// same instance
		return false
	}
	if !isGeneralyValidAsCandidateSiblingOfIntermediateMaster(sibling) {
		return false
	}
	if sibling.HasReplicationFilters != intermediateMasterInstance.HasReplicationFilters {
		return false
	}
	if sibling.IsBinlogServer() != intermediateMasterInstance.IsBinlogServer() {
		// When both are binlog servers, failover is trivial.
		// When failed IM is binlog server, its sibling is still valid, but we catually prefer to just repoint the slave up -- simplest!
		return false
	}
	if sibling.ExecBinlogCoordinates.SmallerThan(&intermediateMasterInstance.ExecBinlogCoordinates) {
		return false
	}
	return true
}
Esempio n. 5
0
func (s *TestSuite) TestNextGTID(c *C) {
	{
		i := inst.Instance{ExecutedGtidSet: "4f6d62ed-df65-11e3-b395-60672090eb04:1,b9b4712a-df64-11e3-b391-60672090eb04:1-6"}
		nextGTID, err := i.NextGTID()
		c.Assert(err, IsNil)
		c.Assert(nextGTID, Equals, "b9b4712a-df64-11e3-b391-60672090eb04:7")
	}
	{
		i := inst.Instance{ExecutedGtidSet: "b9b4712a-df64-11e3-b391-60672090eb04:1-6"}
		nextGTID, err := i.NextGTID()
		c.Assert(err, IsNil)
		c.Assert(nextGTID, Equals, "b9b4712a-df64-11e3-b391-60672090eb04:7")
	}
	{
		i := inst.Instance{ExecutedGtidSet: "b9b4712a-df64-11e3-b391-60672090eb04:6"}
		nextGTID, err := i.NextGTID()
		c.Assert(err, IsNil)
		c.Assert(nextGTID, Equals, "b9b4712a-df64-11e3-b391-60672090eb04:7")
	}
}
Esempio n. 6
0
func (s *TestSuite) TestCanReplicateFrom(c *C) {
	i55 := inst.Instance{Key: key1, Version: "5.5"}
	i56 := inst.Instance{Key: key2, Version: "5.6"}

	var canReplicate bool
	canReplicate, _ = i56.CanReplicateFrom(&i55)
	c.Assert(canReplicate, Equals, false) //binlog not yet enabled

	i55.LogBinEnabled = true
	i55.LogSlaveUpdatesEnabled = true
	i56.LogBinEnabled = true
	i56.LogSlaveUpdatesEnabled = true

	canReplicate, _ = i56.CanReplicateFrom(&i55)
	c.Assert(canReplicate, Equals, false) //serverid not set
	i55.ServerID = 55
	i56.ServerID = 56

	canReplicate, err := i56.CanReplicateFrom(&i55)
	c.Assert(err, IsNil)
	c.Assert(canReplicate, Equals, true)
	canReplicate, _ = i55.CanReplicateFrom(&i56)
	c.Assert(canReplicate, Equals, false)

	iStatement := inst.Instance{Key: key1, Binlog_format: "STATEMENT", ServerID: 1, Version: "5.5", LogBinEnabled: true, LogSlaveUpdatesEnabled: true}
	iRow := inst.Instance{Key: key2, Binlog_format: "ROW", ServerID: 2, Version: "5.5", LogBinEnabled: true, LogSlaveUpdatesEnabled: true}
	canReplicate, err = iRow.CanReplicateFrom(&iStatement)
	c.Assert(err, IsNil)
	c.Assert(canReplicate, Equals, true)
	canReplicate, _ = iStatement.CanReplicateFrom(&iRow)
	c.Assert(canReplicate, Equals, false)
}
Esempio n. 7
0
func (s *TestSuite) TestIsVersion(c *C) {
	i51 := inst.Instance{Version: "5.1.19"}
	i55 := inst.Instance{Version: "5.5.17-debug"}
	i56 := inst.Instance{Version: "5.6.20"}
	i57 := inst.Instance{Version: "5.7.8-log"}

	c.Assert(i51.IsMySQL51(), Equals, true)
	c.Assert(i55.IsMySQL55(), Equals, true)
	c.Assert(i56.IsMySQL56(), Equals, true)
	c.Assert(i55.IsMySQL56(), Equals, false)
	c.Assert(i57.IsMySQL57(), Equals, true)
	c.Assert(i56.IsMySQL57(), Equals, false)
}