radondb / xenon

@@ -305,6 +305,7 @@
Loading
305 305
		Master_Port:   m.conf.Port,
306 306
		Repl_User:     m.conf.ReplUser,
307 307
		Repl_Password: m.conf.ReplPasswd,
308 +
		// Note: Repl_GTID_Purged cannot send to follower
308 309
	}
309 310
}
310 311

@@ -157,6 +157,9 @@
Loading
157 157
158 158
	// mysql replication user pwd
159 159
	ReplPasswd string
160 +
161 +
	// replication Gtid Purged
162 +
	ReplGtidPurged string
160 163
}
161 164
162 165
func DefaultMysqlConfig() *MysqlConfig {
@@ -174,6 +177,7 @@
Loading
174 177
		ReplHost:                   "127.0.0.1",
175 178
		ReplUser:                   "repl",
176 179
		ReplPasswd:                 "repl",
180 +
		ReplGtidPurged:             "",
177 181
	}
178 182
}
179 183
@@ -191,12 +195,16 @@
Loading
191 195
type ReplicationConfig struct {
192 196
	User   string `json:"user"`
193 197
	Passwd string `json:"passwd"`
198 +
199 +
	GtidPurged string `json:"gtid-purged"`
194 200
}
195 201
196 202
func DefaultReplicationConfig() *ReplicationConfig {
197 203
	return &ReplicationConfig{
198 204
		User:   "repl",
199 205
		Passwd: "repl",
206 +
207 +
		GtidPurged: "",
200 208
	}
201 209
}
202 210
@@ -358,6 +366,8 @@
Loading
358 366
	// mysql
359 367
	conf.Mysql.ReplUser = conf.Replication.User
360 368
	conf.Mysql.ReplPasswd = conf.Replication.Passwd
369 +
	conf.Mysql.ReplGtidPurged = conf.Replication.GtidPurged
370 +
361 371
	conf.Mysql.ReplHost = strings.Split(conf.Server.Endpoint, ":")[0]
362 372
	return conf, nil
363 373
}

@@ -198,6 +198,11 @@
Loading
198 198
func (my *MysqlBase) ChangeMasterTo(db *sql.DB, master *model.Repl) error {
199 199
	cmds := []string{}
200 200
	cmds = append(cmds, "STOP SLAVE")
201 +
	if master.Repl_GTID_Purged != "" {
202 +
		cmds = append(cmds, "RESET MASTER")
203 +
		cmds = append(cmds, "RESET SLAVE ALL")
204 +
		cmds = append(cmds, fmt.Sprintf("SET GLOBAL gtid_purged='%s'", master.Repl_GTID_Purged))
205 +
	}
201 206
	cmds = append(cmds, my.changeMasterToCommands(master)...)
202 207
	cmds = append(cmds, "START SLAVE")
203 208
	return ExecuteSuperQueryListWithTimeout(db, my.queryTimeout, cmds)

@@ -164,7 +164,7 @@
Loading
164 164
			}
165 165
166 166
			r.WARNING("get.heartbeat.from[N:%v, V:%v, E:%v].change.mysql.master", req.GetFrom(), req.GetViewID(), req.GetEpochID())
167 -
167 +
			req.Repl.Repl_GTID_Purged = r.Raft.mysql.GetReplGtidPurged()
168 168
			if err := r.mysql.ChangeMasterTo(&req.Repl); err != nil {
169 169
				r.ERROR("change.master.to[FROM:%v, GTID:%v].error[%v]", req.GetFrom(), req.GetRepl(), err)
170 170
				// ChangeToMasterError is true, means we can't promotable to CANDIDATE.

@@ -188,3 +188,8 @@
Loading
188 188
	}
189 189
	return m.db, nil
190 190
}
191 +
192 +
// Get ReplGtidPurged
193 +
func (m *Mysql) GetReplGtidPurged() string {
194 +
	return m.conf.ReplGtidPurged
195 +
}

@@ -48,7 +48,6 @@
Loading
48 48
	req.IdlePeers = p.raft.getIdlePeers()
49 49
	req.GTID = p.raft.getGTID()
50 50
	req.Repl = p.raft.mysql.GetRepl()
51 -
52 51
	client, cleanup, err := p.NewClient()
53 52
	if err != nil {
54 53
		p.raft.ERROR("send.heartbeat.to.peer[%v].new.client.error[%v]", p.getID(), err)
Files Coverage
src 69%
Project Totals (51 files) 69%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading